home *** CD-ROM | disk | FTP | other *** search
Text File | 1990-10-25 | 168.5 KB | 4,052 lines | [TEXT/MPS ] |
- {[a-,body+,h-,o=100,r+,rec+,t=4,u+,#+,j=20/57/1$,n-]} { Pasmat format control line }
- { UMacApp.p }
- { Copyright © 1984-1990 by Apple Computer Inc. All rights reserved. }
-
- { ??? Comments that contain '???' (such as this one) indicate issues that need
- to be resolved sooner or later. ???
-
- The MacApp® team wishes to thank MADA, Carl Nelson, Robin Mair and Jeff Alger for
- generously allowing us to us the MADA MacApp 2.0 Condensed reference text freely.
- This has allowed us to document a number of "historical" interfaces. }
-
- {$IFC UNDEFINED UsingIncludes}
- {$SETC UsingIncludes := FALSE}
- {$ENDC}
-
- {$IFC NOT UsingIncludes}
- UNIT UMacApp;
-
- INTERFACE
- {$ENDC}
-
- {$IFC UNDEFINED __UMacApp__}
- {$SETC __UMacApp__ := FALSE}
- {$ENDC}
-
- {$IFC NOT __UMacApp__}
- {$SETC __UMacApp__ := TRUE}
-
- { • Required for this unit's interface. Auto-Include them }
- {$SETC UMacAppIncludes := UsingIncludes}
- {$SETC UsingIncludes := TRUE}
- {$I+}
- {$IFC UNDEFINED __UMacAppUtilities__} {$I UMacAppUtilities.p} {$ENDC}
- {$IFC UNDEFINED __UObject__} {$I UObject.p} {$ENDC}
- {$IFC UNDEFINED __UList__} {$I UList.p} {$ENDC}
- {$IFC UNDEFINED __UAssociation__} {$I UAssociation.p} {$ENDC}
- {$IFC UNDEFINED __UFailure__} {$I UFailure.p} {$ENDC}
- {$IFC UNDEFINED __UPatch__} {$I UPatch.p} {$ENDC}
- {$IFC UNDEFINED __UMemory__} {$I UMemory.p} {$ENDC}
- {$IFC UNDEFINED __UMenuSetup__} {$I UMenuSetup.p} {$ENDC}
- {$IFC UNDEFINED __UViewCoords__} {$I UViewCoords.p} {$ENDC}
-
- {$IFC UNDEFINED UsingScrap} {$I Scrap.p} {$ENDC}
- {$IFC UNDEFINED UsingWindows} {$I Windows.p} {$ENDC}
- {$IFC UNDEFINED UsingDialogs} {$I Dialogs.p} {$ENDC}
- {$SETC UsingIncludes := UMacAppIncludes}
-
- CONST
- kCopyright =
- 'MacApp® 2.0.1 Copyright © 1984-1990 Apple Computer, Inc. All rights reserved.'
- ;
-
- { M E N U S }
- kMBarDisplayed = 128; { Default 'MBAR' id of the menus that are
- read in and installed in menu bar }
- kMBarNotDisplayed = 129; { Default 'MBAR' id of the menus that are
- read in but not installed }
- kMBarHierarchical = 130; { Default 'MBAR' id of the menus that pop up
- when a menu item is choosen }
-
- { C O M M A N D S }
-
- { Negative numbers and positive numbers up to 999 are reserved by MacApp }
- { Predefined command numbers ??? Renumber these more logically ??? }
- { Not all of these are caught by MacApp.
- "<!>" means MacApp catches it.
- "<&>" means TEView catches it.
- "<->" means the application must catch it if it is used as a
- command number in any menu."
-
- {Special command codes }
-
- cNoCommand = 0; { <!> Command number representing no command
- }
- cCantUndo = - 1; { <!> Passed to TApplication.SetUndoText to
- indicate that the command cannot be
- undone. }
-
- { Apple-menu commands }
-
- cAboutApp = 1; { <!> "About <appname>…" }
-
- { File-menu filing commands }
-
- cNew = 10; { <!> "New" (??? reserve a range of NEW
- commands ???) }
- cNewLast = 19;
- cOpen = 20; { <!> "Open …" (??? reserve a range of OPEN
- commands ???) }
- cOpenLast = 29;
-
- cSave = 30; { <!> "Save" }
- cClose = 31; { <!> "Close" }
- cSaveAs = 32; { <!> "Save as…" }
- cSaveCopy = 33; { <!> "Save a Copy in …" }
- cRevert = 34; { <!> "Revert" (to previous version) }
- cShowClipboard = 35; { <!> "Show Clipboard"/"Hide Clipboard" }
- cQuit = 36; { <!> "Quit" }
-
- { Edit-menu commands }
-
- { For the following command numbers, we must guarantee that
- <command number> - cEditBase = <appropriate number to pass to
- SystemEdit>. This relationship is enforced in
- TApplication.IApplication. }
- cEditBase = 101; { start of standard editing commands }
- cUndo = 101; { <!> "Undo <command>"/"Redo <command>" }
- cEditSep = 102; { line separating UNDO from CUT }
- cCut = 103; { <&> "Cut" }
- cCopy = 104; { <&> "Copy" }
- cPaste = 105; { <&> "Paste" }
- cClear = 106; { <-> "Clear" }
- cEditLast = cClear;
-
- cSelectAll = 110; { <&> "Select All" }
-
- cTyping = 120; { for use in a TTypingCommand }
- cMouseCommand = 121; { generic mouse command }
-
- cStyleChange = 130; { "Menu" command for style change }
- cRememberStyle = 131; { "Menu" command for remembering present
- style }
-
- { Finder pseudo-commands }
-
- cFinderNew = 40; { <!> The user selected the tool icon in the
- Finder and chose "Open" }
- cFinderPrint = 41; { <!> The user selected document icons in
- the Finder and chose "Print" }
- cFinderOpen = 42; { <!> The user selected document icons in
- the Finder and chose "Open" }
-
- { File-menu printing commands }
-
- cPrFileBase = 176; { Command numbers between cPrFileBase and
- cPrFileMax are sent to a document's
- fDocPrintHandler even if it is not in the
- fTarget chain }
- cPrFileMax = 195;
-
- cPageSetup = 176; { <!> "Page Setup…" }
- cPrintOne = 177; { <!> "Print One" }
- cPrint = 178; { <!> "Print…" }
- cPrintToFile = 179; { <!> "Print to file…" }
-
- cPrintSpoolFile = 190; { <-> "Print spooled file…" }
-
- cPrViewBase = 201; { Command numbers between cPrViewBase and
- cPrViewMax are printing commands applied
- to a displayed view in the fTarget chain }
- cPrViewMax = 250;
-
- cShowBorders = 199; { <!> Toggle. "Show view borders"--also
- usable outside Debug menu }
-
- { Zooming commands } { Not being used at present }
-
- cReduce50 = 301; { <-> "Reduce 50%" }
- cReduceToFit = 302; { <-> "Reduce to Fit" }
- cShowFullSize = 303; { <-> "Show Full Size" }
-
- { Control tracking }
- cTrackingControl = 400;
-
- { Debug-menu commands. Flag toggled by "cFoo" is called "gFoo" for any
- "Foo" }
-
- cIdentifySoftware = 900; { <!> Action. "Show Software Version"--
- WriteLn version info }
- cExperimenting = 901; { <!> Toggle. "Enable experimental features"
- }
- cReportMenuChoices = 902; { <!> Toggle. "Trace menu commands"--
- WriteLn menu choices }
- cIntenseDebugging = 904; { <!> Toggle. "Intense Debugging" }
- cTraceSetupMenus = 905; { <!> Toggle. "Allow Trace of Menu Setups"
- if gTrace is also on }
- cTraceIdle = 906; { <!> Toggle. "Allow Trace during Idle" if
- gTrace is also on }
- cDebugPrinting = 912; { <!> Toggle. "Debug Printing" }
- cReportEvt = 914; { <!> Toggle. "Report Events"--WriteLn
- events received from queue }
- cDoFirstClick = 915; { <!> Toggle. "'Do First Click' for this
- window" }
- cVarClipPicSize = 916; { <!> Toggle. "Scale Pictures in Clipboard
- to Window" }
- cRefreshFrontWindow = 917; { <!> Action. "Refresh Front Window" }
- cNewInspectorWindow = 918; { <!> Action. "Open new inspector window" }
- cModalToggle = 919; { <!> Toggle. "Make front window
- modal/modeless"}
- cDebugWind = 913; { <!> Action. "Show Debug Window" }
- cEnterMacAppDebugger = 920; { <!> Action. "Enter the MacApp Debugger" }
-
- cSetSysJust = 921; { <!> Action. "Switch system justification" }
-
-
- { D E B U G F L A G S }
-
- {$IFC NOT qDebug} { These start with 'g' because they are
- global variables when qDebug is TRUE }
- gExperimenting = FALSE;
- gReportMenuChoices = FALSE;
- gIntenseDebugging = FALSE;
- gDebugPrinting = FALSE;
- gReportEvt = FALSE;
-
- gMemMgtReport = FALSE;
- gAssumeFocused = FALSE;
- {$ENDC}
-
- { A L E R T S }
-
- errReasonID = 128; { resource ID of errs resource describing
- error messages }
- errRecoveryID = 129; { resource ID of errs resource describing
- recovery messages }
- errOperationsID = 130; { resource ID of errs resource containing
- operation strings }
- errAppTable = 1000; { added to the MacApp resource ID to get the
- ID of an application error table }
-
- msgCmdErr = 0; { when added to a command number, gives a
- message value to display the alert "Could
- not complete the … command …" }
- msgAlert = $FFFF0000; { when added to an alert number, gives a
- message value to display that alert }
- msgLookup = $FFFE0000; { when added to an INTEGER, gives a message
- value that will look up the INTEGER in
- table errOperationsID and display the
- alert "Could not … because …" }
- msgAltRecovery = $FFFD0000; { same as msgLookup, except the INTEGER is
- used instead of the error number to lookup
- the recovery string }
-
- msgStrList = 130 * $10000; { Standard list of operation strings used by
- MacApp * $10000 to plunk it into hiwrd }
- msgCancelled = msgStrList; { used with error = noErr if user cancels
- Save, Quit, … }
- msgInitFailed = msgStrList + 1;
- msgSaveFailed = msgStrList + 2;
- msgRevertFailed = msgStrList + 3;
- msgPrintFailed = msgStrList + 4;
- msgNewFailed = msgStrList + 5;
- msgOpenFailed = msgStrList + 6;
- msgSaveAsFailed = msgStrList + 7;
- msgSaveCopyFailed = msgStrList + 8;
- msgDrawFailed = msgStrList + 9;
- msgImportClipFailed = msgStrList + 10;
- msgExportClipFailed = msgStrList + 11;
-
- { error codes used in MacApp; applications should use errors between
- -25000 and -29999 }
-
- errSpooling = - 20000; { print spooling failed OSErr }
- errRevertFNF = - 20001; { Revert failed because file was deleted }
- errFileChanged = - 20002; { disk file modification date changed }
- errSaveAgain = - 20003; { Save As / Save a Copy in an opened
- document }
- errFTypeChanged = - 20004; { disk file type changed }
- errNoPrintDrvr = - 20005; { print driver file not found }
- errNotMyType = - 20006; { can't open this file type }
- errNotImplemented = - 20007; { Signaled when a function is not yet
- implemented }
- errMissingClass = - 20008; { Signaled when a class is missing. Usually
- due to failure to dead-strip suppress when
- creating objects any other way than by "NEW" }
-
- { Alerts 0 - 249 are reserved by MacApp. }
-
- phGenError = 128; { 'Could not ^2, because ^0. ^1' }
- phCmdErr = 129; { 'Could not complete the “^2” command
- because ^0. ^1'. }
- phUnknownErr = 130; { 'Could not complete your request because
- ^0. ^1'; only used if no operation is
- supplied. }
- phSaveChanges = 131; { 'Save Changes Before Closing?' }
- phRevert = 132; { 'Revert to last version saved?' }
- phFileChanged = 133; { 'File changed since last save.' }
- phPurgeOld = 134; { 'OK to purge old version before saving new
- one?' }
- phReopenDoc = 135; { 'Document is already open.' }
- phSpaceIsLow = 136; { 'Space is low' }
- phUnsupportedConfiguration = 137; { 'Can't start app because your machine is
- too wimpy!' }
- phOfferReadOnly = 138; { 'Can't open for file for write. Open
- read-only?' }
-
- phTooManyChars = 150; { 'Too Many Characters', used to reject
- paste or keystrokes in UDialog and UTEView
- }
-
- phStylesTooBig = 151; { 'Too Many Styles', used to reject the
- styles portion of a paste in UTEView }
-
- phAboutApp = 201; { Can hold the 'About <appName>…' message }
-
- phUnimplemented = 202; { 'This feature not yet implemented' }
-
- { M A C A P P B U Z Z - S T R I N G R E S O U R C E }
- kIDBuzzString = 250; { std list of buzzwords stored as 'STR#'
- resources. This string list is reserved
- for MacApp; you should choose a different
- resource ID for your strings. }
-
- { Indices for strings in the buzz-string resource }
- bzSaveAs = 1; { 'Save This Document As:' }
- bzSaveCopy = 2; { 'Save a Copy In:' }
- bzShowClip = 3; { 'Show Clipboard' }
- bzHideClip = 4; { 'Hide Cllpboard' }
- bzUndo = 5; { 'Undo x' }
- bzRedo = 6; { 'Redo x' }
- bzCantDraw = 7; { 'Unable to draw contents of window' }
- bzUntitled = 8; { name of untitled document; if blank then
- this is taken from the window title
- template; if this includes the string
- '<<<>>>' then MacApp will substitute a
- number for the string (e.g., if the buzz
- string contains 'Untitled-<<<>>>' then
- untitled windows will be named
- 'Untitled-1', Untitled-2, … }
- bzClosing = 9; { 'closing' }
- bzQuitting = 10; { 'quitting' }
- bzCantUndo = 11; { 'Can’t Undo' }
- bzSaveAnyways = 12; { 'save' }
- bzRevertAnyways = 13; { 'revert' }
-
- { D E B U G B U Z Z - S T R I N G R E S O U R C E }
- kDebugBuzzStrings = 251; { Debug buzzwords STR# resource }
- bzMakeModal = 1; { 'Make Front Window Modal' }
- bzMakeModeless = 2; { 'Make Front Window Modeless' }
- bzDoFirstClick = 3; { 'Do First Click For This Window' }
- bzDontDoFirstClick = 4; { 'Don't Do First Click For This Window' }
- bzSetRightSysJust = 5; { Set system to right justification }
- bzSetLeftSysJust = 6; { Set system to left justification }
-
- { R E S O U R C E I D S }
- { Negative numbers and numbers up to 127 are reserved by Apple }
- { Positive numbers from 128 up to 999 are reserved by MacApp }
- kDefaultCredits = 1001; { People responsible for the application }
- kIDClipWindow = 200; { window displaying the Clipboard }
- kScrollBarId = 202; { for when we create scrollers from
- resources }
- kDebugParamsID = 300; { debug window }
-
- { V I E W I D E N T I F I E R S }
- { These follow the same reservation rules as resource types }
-
- kDefaultWindowID = 1001; { Window view resource installed by default
- in TDocument }
- kDefaultViewID = 1002; { View resource installed by default in
- TDocument }
- kIDDefaultView = 'DFLT'; { View ID of default view }
- kIDClipView = 'CLIP'; { identifier of the clipboard "orhanage" }
-
- { O B J E C T S I G N A T U R E S }
- { These follow the same reservation rules as resource types }
- { The signature is used to search the signature table and create
- an object "by signature" If the signature's entry in the table has
- been updated with a new class then an object of that class will be created. }
-
- kStdDocument = 'docu';
- kStdTracker = 'trak';
- kStdList = 'list';
-
- kStdButton = 'butn';
- kStdCheckBox = 'chkb';
- kStdCluster = 'clus';
- kStdControl = 'cntl';
- kStdDefaultView = 'dflt';
- kStdDialogView = 'dlog';
- kStdEditText = 'edit';
- kStdGridView = 'grid';
- kStdIcon = 'icon';
- kStdNumberText = 'nmbr';
- kStdPattern = 'patn';
- kStdPicture = 'pict';
- kStdPopup = 'popp';
- kStdRadio = 'radb';
- kStdScroller = 'scrl';
- kStdSScrollBar = 'sbar';
- kStdStaticText = 'stat';
- kStdTEView = 'tevw';
- kStdTextGridView = 'txtg';
- kStdTextListView = 'lstg';
- kStdView = 'view';
- kStdWindow = 'wind';
-
- { H I G H L I G H T I N G }
- hlOff = 1; { the selection is to be unhighlighted }
- hlDim = 2; { the selection is to be dimly highlighted }
- hlOn = 4; { the selection is to be fully highlighted }
-
- { these constants can be used to test for combinations of fromHL+toHL,
- when you do not care which is from and which is to }
- hlOffDim = hlOff + hlDim;
- hlDimOff = hlOffDim;
- hlDimOn = hlDim + hlOn;
- hlOnDim = hlDimOn;
- hlOffOn = hlOff + hlOn;
- hlOnOff = hlOffOn;
-
- { C H O I C E S }
-
- { Negative numbers and positive numbers up to 999 are reserved by MacApp }
- mOKHit = 1;
- mCancelHit = 2;
- mButtonHit = 3;
- mCheckBoxHit = 4;
- mClusterHit = 5;
- mEditTextHit = 6;
- mIconHit = 7;
- mListItemHit = 8;
- mListScrollBarHit = 9;
- mPictureHit = 10;
- mPopupHit = 11;
- mRadioHit = 12;
- mStaticTextHit = 13;
- mHScrollBarHit = 14;
- mVScrollBarHit = 15;
- mEditTabKey = 16;
- mEditReturnKey = 17;
- mEditEnterKey = 18;
- mPatternHit = 19;
- mControlHit = 20;
- mCancelKey = 21;
- mDefaultKey = 22;
-
- kNoIdentifier = ' ';
- kNoTemplate = - 1;
- kNoResource = - 1;
-
- { M I S C E L L A N E O U S }
- kStdMainFileType = 'TEXT'; { the file type identifier used by default }
-
- kYesButton = 1; { the 'Yes' button in various dialogs }
- kNoButton = 3; { the 'No' button in various dialogs }
-
- kLowSpaceInterval = 2 * 60 * 60; { default low space msg interval (2 seconds)
- }
-
- kStdScrollUnit = 16; { default value of fScrollUnit used by
- scrollers }
-
- kSBarSize = 16;
- kSBarSizeMinus1 = kSBarSize - 1;
- { !!! Prefer the above names }
- kStdSzSBar = 16; { width/height of a standard
- vertical/horizontal scroll bar }
- kStdSzMinus1SBar = kStdSzSBar - 1;
-
- kStdStaggerAmount = 16; { standard # of pixels to stagger windows }
-
- kMaxIdleTime = MAXLONGINT; { Default tick count sent to WaitNextEvent }
-
- { Numbers to pass to SystemEdit }
- kSysUndo = 0;
- kSysCut = 2;
- kSysCopy = 3;
- kSysPaste = 4;
- kSysClear = 5;
-
- {$IFC qDebug}
- kRsrcCheckInterval = 100;
- {$ENDC}
-
- kPriorityLowest = 127; { Low priority commands are considered last
- }
- kPriorityLow = kPriorityLowest - 32; { Low priority commands are considered last
- }
- kPriorityNormal = 64; { Normal priority assigned to commands by
- default }
- kPriorityHighest = 0; { High priority commands take precedence }
- kPriorityHigh = kPriorityHighest + 32; { High priority commands take precedence }
-
- kBuild = TRUE; { Pass to TWindow.BuildWindowRgns }
- kAllowApplicationToSleep = TRUE; { Pass to TApplication.PollEvent if the
- application is allowed to sleep if there
- are no events pending. }
- { P R I N T I N G }
- kSquareDots = TRUE; { Square dots in Printing }
- kFixedSize = TRUE; { Fixed Page Size in Printing }
-
- kPrintInfoSize = 120; { size in bytes of printInfo record }
-
- { size in bytes of the overhead for a resource file;
- kRsrcFileOverhead is added in TDocument.DoNeedDiskSpace if the
- document uses the rsrc fork.
- You should add kRsrcTypeOverhead for each unique type you use
- plus kRsrcOverhead for each resoruce you use
- plus the total bytes in all the resources
- plus the length of all the names for named resources. }
- kRsrcFileOverhead = 256 + { resource header & stuff }
- 30 { fixed part of resource map } ;
- kRsrcTypeOverhead = 8; { overhead for each resource type }
- kRsrcOverhead = 16; { overhead for each resource }
-
- { ??? }
- kViewRsrcExpandAmt = $400; { ??? Is 1K enough for expansion, or too
- much maybe??? }
-
- { debugging info }
- kDebugFont = {monaco} 4; { Font for Debug Window }
- kDebugSize = 9; { Font size for Debug Window }
-
- { argument of TDocument.DoMakeViews }
- kForDisplay = FALSE;
- kForPrinting = NOT kForDisplay;
-
- { arguments of TScroller.IScroller }
- kWantHScrollBar = TRUE;
- kWantVScrollBar = TRUE;
-
- { arguments of TDocument.Save }
- kAskForFilename = TRUE;
- kMakingCopy = TRUE;
- kSwitchToTarget = NOT kMakingCopy;
-
- { argument of NewPaletteWindow }
- kLeftPalette = h;
- kTopPalette = v;
-
- { argument of TApplication.SetUndoText }
- kShowUndo = TRUE;
- kShowRedo = FALSE;
- kShowCantUndo = kShowUndo;
-
- { argument of TDocument.IDocument }
- kUsesDataFork = TRUE;
- kUsesRsrcFork = TRUE;
- kDataOpen = TRUE;
- kRsrcOpen = TRUE;
-
- { argument of TDocument.OpenDocFile }
- kKeepingOpen = TRUE;
- kReadingFile = TRUE;
-
- kVisible = TRUE;
- kInvisible = FALSE;
-
- { arguments to routines with a 'redraw' parameter }
- kRedraw = TRUE;
- kDontRedraw = FALSE;
-
- { arguments to routines with an 'invalidate' parameter }
- kInvalidate = TRUE;
- kDontInvalidate = FALSE;
-
- { MultiFinder event message masks }
- kSuspendOrResume = $01;
- kMouseMovedMessage = $FA;
-
- kMaxSignatures = 32;
-
- TYPE
-
- { E V E N T S }
-
- EventRecordPtr = ^EventRecord; { EventRecord is a ToolBox type. The pointer
- type _MUST_ be declared first since the
- record is self referential }
- EventInfo = RECORD { stores more information about the event in
- an unpacked form }
- thePEvent: EventRecordPtr; { pointer to the original packed ToolBox
- event record }
- theBtnState: BOOLEAN; { bits found in the modifiers field of an
- EventRecord }
- theCmdKey: BOOLEAN; { Was Command key depressed? }
- theShiftKey: BOOLEAN; { Was Shift key depressed? }
- theAlphaLock: BOOLEAN; { Was Alpha Lock depressed? }
- theOptionKey: BOOLEAN; { Was Option key depressed? }
- theControlKey: BOOLEAN; { Was Control key depressed? }
- theAutoKey: BOOLEAN; { TRUE if this was an auto key event }
- theCharacter: Char; { IF a key event the char that the event
- translates to !!! what about 16 bit chars? }
- theKeyCode: INTEGER; { IF a key event the virtual key code that the
- event translates to }
-
- theClickCount: INTEGER; { 0 = event was not a mouse down; 1-N = # of
- multiple clicks }
- affectsMenus: BOOLEAN; { True means the menus must be setup after
- the event }
- END;
- PEventRecord = EventRecordPtr; { Left in for compatibility (2.0) }
-
- IdlePhase = (idleBegin, idleContinue, idleEnd);
- TrackPhase = (trackPress {actually trackBegin} , trackMove {actually
- trackContinue} , trackRelease {actually trackEnd} );
-
- { V I E W C O O R D I N A T E S }
-
- SizeDeterminer = { Tells how a view's size is to be
- determined; specified separately in each
- dimension. }
- (sizeSuperView, { View is the same size as its superview }
- sizeRelSuperView, { View size is relative to the superview's
- size }
- sizePage, { View to be the size of one page }
- sizeFillPages, { View to grow upward to fill an exact
- number of pages }
- sizeVariable, { View size fluctuates according to
- app-specific criteria }
- sizeFixed); { No special default handling of size issues
- }
-
- { H I G H L I G H T I N G }
- HLState = hlOff..hlOn;
-
- { D O C U M E N T S }
- { How to save a document in place, if MacApp decides this is needed.
- sipNever: never save on top of old file (ie., save will fail if
- there is not enough disk space)
- sipAlways: save on top of old file without asking user
- sipAskUser: save on top, but only if user confirms
- }
- SIPChoice = (sipNever, sipAlways, sipAskUser);
-
- { O T H E R }
- AppFilePtr = ^AppFile; { AppFile is segment loader section of
- Inside Macintosh }
- PAppFile = AppFilePtr; { Left in for compatibility (2.0) }
-
- ArrTypeList = ARRAY [1..8000] OF OSType;
- TypeListPtr = ^ArrTypeList; { Preferred }
- TypeListHandle = ^TypeListPtr; { Preferred }
- PTypeList = TypeListPtr; { Left in for compatibility (2.0) }
- HTypeList = TypeListHandle; { Left in for compatibility (2.0) }
-
- CommandPriority = kPriorityHighest..kPriorityLowest; { Command priorities }
-
- {$IFC qHasForward}
- TCommand = OBJECT; FORWARD;
- TDocument = OBJECT; FORWARD;
- TPrintHandler = OBJECT; FORWARD;
- TView = OBJECT; FORWARD;
- TWindow = OBJECT; FORWARD;
- TCommandList = OBJECT; FORWARD;
- TScroller = OBJECT; FORWARD;
- TSScrollBar = OBJECT; FORWARD;
- {$EndC}
-
- TEvtHandler = OBJECT (TObject) { The TEvtHandler type represents abstract
- objects that handle certain kinds of
- events: Key events: both key down and auto
- key events, menu events: both enabling
- menus and menu items and processing menu
- commands, Read to/write from Disk, Idle
- events: when there are no other events to
- handle, Actual events: EvtHandlers -
- through their method 'DoHandleEvent' may
- intercept and handle actual ToolBox events
- Termination: when the application quits
- TEvtHandler are linked into a list with
- the most specific object (usually a
- selection) at the head of the list. The
- global variable 'gTarget' contains the
- head of the list. (When a window is
- deactivated, this global variable is
- cached in the window object, and retrieved
- when it is later activated.) For these
- kinds of events, the target (gTarget) gets
- the first crack at handling the event. The
- default implementation of the methods of
- TEvtHandler is to pass the event to the
- next element of the list. }
-
- fNextHandler: TEvtHandler; { the next element of the list, or NIL }
- fIdleFreq: LONGINT; { the minimum number of ticks that can pass
- before my DoIdle is called. 0 = call as
- often as possible. n..kMaxIdleTime = call
- every fIdleFreq ticks. }
- fLastIdle: LONGINT; { the tick count the last time my DoIdle was
- called. }
-
- { Init & Free }
- PROCEDURE TEvtHandler.IEvtHandler(itsNextHandler: TEvtHandler);
- { Sets up the reference to the next handler by setting the fNextHandler field to
- 'itsNextHandler', also sets the idle frequency and resets fLastIdle field to zero.
- }
-
- PROCEDURE TEvtHandler.Free; OVERRIDE;
- { Before calling inherited Free, changes the target to the application if the next
- handler is NIL or the next handler if there is one. }
-
- { Termination }
- PROCEDURE TEvtHandler.Terminate;
- { Does nothing in this class. }
-
- { Chainwalking }
- PROCEDURE TEvtHandler.EachHandler(PROCEDURE
- DoToEvtHandler(anEvtHandler: TEvtHandler));
- { Performs 'DoToEvtHandler' to aFirstHandler, then to its fNextHandler, etc., onward
- until the fNextHandler chain ends at NIL }
-
- FUNCTION TEvtHandler.FirstHandlerThat(FUNCTION
- TestEvtHandler(anEvtHandler: TEvtHandler):
- BOOLEAN): TEvtHandler;
- { Calls TestEvtHandler for each event handler until TestEvtHandler returns true.
- Returns the TEvtHandler object for which TestEvtHandler returned true, or NIL if
- TestEvtHandler never returned true. }
-
- FUNCTION TEvtHandler.AddHandler(headOfChain: TEvtHandler): TEvtHandler;
- { Adds SELF from the chain of handlers starting at headOfChain. Returns the new
- head of chain. }
-
- FUNCTION TEvtHandler.RemoveHandler(headOfChain: TEvtHandler): TEvtHandler;
- { Removes SELF from the chain of handlers starting at headOfChain. Returns the new
- head of chain (if self was the head then there _must_ be a new head. }
-
- { Debugging }
- PROCEDURE TEvtHandler.IdentifySoftware;
- { If fNextHandler is not NIL calls the next handler's IdentifySoftware method. }
-
- FUNCTION TEvtHandler.LookupSymbol(VAR sym: Str255): LONGINT;
- { Called by the debugger to translate a symbol into a number; default passes to the
- fNextHandler. sym will be uppercased. Return of -1 means symbol was not found. If
- sym = '?' then writeln a list of available symbols. }
-
- PROCEDURE TEvtHandler.Fields(PROCEDURE
- DoToField(fieldName: Str255;
- fieldAddr: Ptr;
- fieldType: INTEGER)); OVERRIDE;
- { Used by the Inspector and the Debugger to display the contents of this class's
- fields. }
-
- { Events }
- FUNCTION TEvtHandler.DoIdle(phase: IdlePhase): BOOLEAN;
- { Returns true if it frees itself so caller can know }
-
- FUNCTION TEvtHandler.DoHandleEvent(nextEvent: EventRecordPtr;
- VAR commandToPerform: TCommand): BOOLEAN;
- { Handle the event and return TRUE if I want it, else I don't handle it, and return
- FALSE }
-
- { Double/Triple Clicks }
- FUNCTION TEvtHandler.DoMultiClick(lastDownPt, newDownPt: Point): BOOLEAN;
- { Called by TApplication.CountClicks. Should return TRUE if the 2 points are close
- enough to be considered part of a double/triple click. (Both points are in global
- coordinates.) This is only called if the mouse down was within the proper time
- range of the previous mouse up. Default is to pass message to the nextEventHandler
- (if one exists), otherise to require that the sum of the x & y distances is <=
- gStdHysteresis. }
-
- { Key Events }
- FUNCTION TEvtHandler.DoKeyCommand(ch: Char;
- aKeyCode: INTEGER;
- VAR info: EventInfo): TCommand;
- { Handles all keystrokes except those with the command key held down. }
-
- FUNCTION TEvtHandler.DoCommandKey(ch: Char;
- VAR info: EventInfo): TCommand;
- { Handles command-key combinations only. }
-
- PROCEDURE TEvtHandler.KeyEventToComponents(VAR info: EventInfo);
- { Intended to extract character components of an event in a script manager
- compatible way. Default just forwards to next handler }
-
- { MenuEvents }
- FUNCTION TEvtHandler.DoMenuCommand(aCmdNumber: CmdNumber): TCommand;
- { If the handler can perform the command it does so by either performing
- the command directly or by returning a TCommand. }
-
- PROCEDURE TEvtHandler.DoSetupMenus;
- { Handles the setup of menus. }
-
- { Help }
-
- FUNCTION TEvtHandler.DoHelp(VAR info: EventInfo;
- VAR message: UNIV LONGINT): TCommand;
- { If fNextHandler is not NIL calls its DoHelp method, otherwise returns NIL. }
-
- { View Creation from Templates}
- FUNCTION TEvtHandler.DoCreateViews(itsDocument: TDocument;
- parentView: TView;
- itsRsrcID: INTEGER;
- subViewOffset: VPoint): TView;
- { This is the method responsible for creating view hierarchies from resource
- templates. If fNextHandler is not NIL it calls its DoCreateViews method. Otherwise
- it creates the desired view heirarchy. }
-
- FUNCTION TEvtHandler.CreateAView(itsDocument: TDocument;
- itsSuperView: TView;
- VAR itsParams: Ptr): TView;
- { For creating a single view from a resource template view. If fNextHandler is not
- NIL calls its CreateAView method, otherwise it proceeds to create the desired view.
- }
-
- { Miscellaneous }
- FUNCTION TEvtHandler.HandlesPrintingCommands: BOOLEAN;
- { If fNextHandler is not NIL calls its same method setting this method to the result,
- otherwise returns FALSE. }
-
- PROCEDURE TEvtHandler.InstallSelection(wasActive, beActive: BOOLEAN);
- { The Target is told to do this after a window is activated or deactivated. }
-
- PROCEDURE TEvtHandler.SetIdleFreq(newIdleFreq: LONGINT);
- { Call to set the handler's idling frequency. }
-
- PROCEDURE TEvtHandler.DoChoice(origView: TView;
- itsChoice: INTEGER);
- { If its next handler is not NIL calls its DoChoice method.
- ??? should change the origView parameter to origHandler in a future version? }
-
- { Command Management }
- PROCEDURE TEvtHandler.CommitLastCommand;
- { Commits the last command by calling its Commit method.
- Default is to hand off to fNextHandler }
-
- FUNCTION TEvtHandler.GetLastCommand: TCommand;
- { Returns the last undoable command. The command returned is not yet committed.
- Default is to hand off to fNextHandler }
-
- FUNCTION TEvtHandler.GetNextCommand: TCommand;
- { Returns a previously posted command. Nil if there are no queued commands.
- Default is to hand off to fNextHandler }
-
- PROCEDURE TEvtHandler.PerformCommand(command: TCommand);
- { Called to perform the given command.
- Default is to hand off to fNextHandler }
-
- PROCEDURE TEvtHandler.PostCommand(command: TCommand);
- { Called to post a command to a queue for later execution.
- Default is to hand off to fNextHandler }
-
- END;
-
- TApplication = OBJECT (TEvtHandler) { The purpose of TApplication is to
- implement the main event loop that all
- Macintosh applications must have. There is
- only one instance of TApplication. One
- thing that TApplication does is to
- interpret the raw events that are posted
- and convert them into higher-level events.
- For example, it converts a click in the
- menu bar into a 'menu event' that contains
- the menu ID/item number that was chosen by
- the user. }
-
- { There are not many TApplication variables--they are mostly global variables, for now… }
-
- fTicksTilNextIdle: LONGINT; { Formerly gIdleFreq. Computed number of
- ticks until the next time
- TApplication.Idle needs to be called to
- dole out idle time. Also is the maximum
- waitTicks that we can hand off to
- GetEvent. }
-
- fTicksOfLastIdle: LONGINT; { Formerly gLastIdle. Time in ticks of the
- last time the active chain and cohandlers
- were idled. }
-
- fCommandQueue: TCommandList; { Commands that were posted for execution }
- fLaunchWithNewDocument: BOOLEAN; { TRUE (the default) to create a new
- untitled document when the application is
- launched without a document. }
- fLastCommand: TCommand; { the last command done or undone by the
- user }
-
- { Init & Free }
- PROCEDURE TApplication.IApplication(itsMainFileType: OSType);
- { itsMainFileType should be the the 4-byte file type that this application
- reads/writes. We require this here so that programmers do not have to explicitly
- override TApplication.SFGetParms and supply the type there. That is the only place
- where the main file type is used. }
-
- PROCEDURE TApplication.GetInspectorName(VAR inspectorName: Str255); OVERRIDE;
- { Used to get this class's name by the Inspector. }
-
- PROCEDURE TApplication.Fields(PROCEDURE
- DoToField(fieldName: Str255;
- fieldAddr: Ptr;
- fieldType: INTEGER)); OVERRIDE;
- { Used by the Inspector and the Debugger to display the contents of this class's
- fields, in this case the global variables. }
-
- { Event Handling }
- FUNCTION TApplication.GetEvent(eventMask: INTEGER;
- sleep: LONGINT;
- cursorRgn: RgnHandle;
- VAR anEvent: EventRecord): BOOLEAN;
- { Calls WaitNextEvent (or GetNextEvent) with the given event mask, sleep, and cursor
- region parameters. You can override this if you have an alternate source for
- events. }
-
- FUNCTION TApplication.HandleAlienEvent(VAR theEventInfo: EventInfo): TCommand;
- { This method is called upon to deal with 'application-specific' events }
-
- PROCEDURE TApplication.MainEventLoop;
- { Loop on PollEvent until the application is done }
-
- PROCEDURE TApplication.DispatchEvent(VAR theEventInfo: EventInfo;
- VAR commandToPerform: TCommand);
-
- PROCEDURE TApplication.HandleEvent(VAR theEvent: EventRecord);
- { When this is called by MacApp, theEvent is a pointer to the global variable
- gLastEvent. In special circumstances, you might 'fake' an event record and pass a
- pointer to it. }
-
- PROCEDURE TApplication.PostHandleEvent(VAR theEventInfo: EventInfo);
-
- FUNCTION TApplication.HandleActivateEvent(VAR theEventInfo: EventInfo): TCommand;
- { Handles activate (and deactivate) events. Calls the window's Activate method, and
- sets gRedrawMenuBar to true if activating the window. Returns NIL. }
-
- FUNCTION TApplication.HandleDiskEvent(VAR theEventInfo: EventInfo): TCommand;
- { Handles disk events. Calls DIBadMount if the high word of theEvent's message is <>
- noErr. Returns NIL. }
-
- PROCEDURE TApplication.KeyEventToComponents(VAR info: EventInfo); OVERRIDE;
- { re-extracts components of an event in a script manager compatible way. }
-
- FUNCTION TApplication.HandleKeyDownEvent(VAR theEventInfo: EventInfo): TCommand;
- { Handles key down events. If the command key is down, then this calls CommandKey.
- Otherwise it calls gTarget.DoKeyCommand. Returns the result of CommandKey or
- DoKeyCommand. }
-
- FUNCTION TApplication.HandleMouseDown(VAR theEventInfo: EventInfo): TCommand;
- { Called when a mouse down occurs; this cases on whereMouseDown and does the right
- thing. }
-
- FUNCTION TApplication.TrackMouse(globalMouse, hysteresis: Point;
- theCommand: TCommand): TCommand;
-
- { Responsible for mouse tracking. }
-
- FUNCTION TApplication.HandleMouseUp(VAR theEventInfo: EventInfo): TCommand;
- { Sets gLastUpTime. Returns NIL. }
-
- FUNCTION TApplication.HandleSystemEvent(VAR theEventInfo: EventInfo): TCommand;
- { Handles "system" events, in particular suspend/resume events and mouse moved
- events. Calls RegainControl if switching in, AboutToLoseControl if switching out,
- or TrackCursor if it is a mouse-moved event. Returns NIL. }
-
- FUNCTION TApplication.HandleUpdateEvent(VAR theEventInfo: EventInfo): TCommand;
- { Handles window update events. Calls UpdateEvent for the window indicate by the
- event, and returns NIL. }
-
- FUNCTION TApplication.IsDeskAccessory(aWMgrWindow: WindowPtr): BOOLEAN;
- { Returns true if the given Window Manager window is a desk accessory. We assume that
- if the window has a negative windowKind then it is a desk accessory. }
-
- PROCEDURE TApplication.OpenDeskAccessory(deskAccName: Str255);
- { Attempts to open the desk accessory whose name is deskAccName. Called from
- TApplication.MenuEvent when an Apple menu item is chosen, and the item has a
- negative command number. }
-
- PROCEDURE TApplication.PollEvent(allowApplicationToSleep: BOOLEAN);
- { Polls for events calling Idle before waitNextEvent if there are no events pending
- and the application is allowed to go to sleep (kAllowApplicationToSleep),
- calls HandleEvent with the event, if there is one. and then idles if necessary. }
-
- PROCEDURE TApplication.Run;
- { HandleFinderRequest, and if not finder printing, call MainEventLoop }
-
- PROCEDURE TApplication.UpdateAllWindows;
- { Process all update events in the queue. }
-
- FUNCTION TApplication.InModalState: BOOLEAN;
- { Returns true if the front window is modal. }
-
- FUNCTION TApplication.InModalMenuState: BOOLEAN;
- { Returns true if the front window does not allow menu commands. }
-
- PROCEDURE TApplication.ReportEvent(VAR theEvent: EventRecord);
- { Displays information about an event to the debugging window. }
-
- { Target and Cohandlers }
- PROCEDURE TApplication.InstallCohandler(aCohandler: TEvtHandler;
- addIt: BOOLEAN);
- { Used to add (addIt = TRUE) or delete (addIt = FALSE) a cohandler to/from the global
- list of cohandlers }
-
- FUNCTION TApplication.GetFrontWindow: TWindow;
- { Returns the window object reference for the frontmost application window (whether
- active or not. Returns nil if the FrontWindow window is not a window object }
-
- FUNCTION TApplication.GetActiveWindow: TWindow;
- { Returns the window object reference for the active application window. Returns nil
- if the FrontWindow window is not a window object }
-
- PROCEDURE TApplication.SetTarget(newTarget: TEvtHandler);
- { Sets the current target (the head of the target chain) for the application. }
-
- { Finder Requests }
- FUNCTION TApplication.CanOpenDocument(itsCmdNumber: CmdNumber;
- VAR anAppFile: AppFile): BOOLEAN;
- { Simulates the filtering done by Std File; this is only called when opening/printing
- documents from the finder; when using Std File, Std File does the filtering. }
-
- PROCEDURE TApplication.HandleFinderRequest;
- { Gets the info from the finder about what files to open/print and opens/prints them.
- }
-
- { Opening / Printing Documents }
- FUNCTION TApplication.AlreadyOpen(fileName: Str255;
- volRefnum: INTEGER): TDocument;
- { Given a name/volRefnum, if that document is already opened, returns the TDocument.
- Otherwise returns NIL. }
-
- FUNCTION TApplication.ChooseDocument(itsCmdNumber: CmdNumber;
- VAR anAppFile: AppFile): BOOLEAN;
- { Call this to make a Std File Get call; returns TRUE is user selected a file. }
-
- FUNCTION TApplication.DoMakeDocument(itsCmdNumber: CmdNumber): TDocument;
- { Must be overridden. Based on itsCmdNumber create a document object of the
- appropriate kind. }
-
- FUNCTION TApplication.KindOfDocument(itsCmdNumber: CmdNumber;
- itsAppFilePtr: AppFilePtr): CmdNumber;
- { Given a cmd number and a specification of the file, return the cmd number to pass
- to DoMakeDocument that indicates the type of document to make; Default is to return
- itsCmdNumber. If you have multiple document types, a good convention is to return
- the cmd numbers assigned to create new documents of each kind. itsAppFilePtr will be
- NIL if we are creating a brand new document, rather than opening an existing
- document. }
-
- PROCEDURE TApplication.OpenNew(itsCmdNumber: CmdNumber);
- { Called when the application is opened (itsCmdNumber = cFinderNew), or when NEW is
- chosen from menu (itsCmdNumber = cNew). If you do not want to create a new document
- when the user opens the application, override this and do nothing if itsCmdNumber =
- cFinderNew. }
-
- PROCEDURE TApplication.OpenOld(itsOpenCmd: CmdNumber;
- anAppFile: AppFile);
- { Called when opening an existing document from finder (itsCmdNumber = cFinderOpen)
- or if OPEN is chosen from menu (itsCmdNumber = cOpen). }
-
- FUNCTION TApplication.PrintDocument(anAppFile: AppFile): BOOLEAN;
- { Called to print a document from the finder. Returns TRUE if the user did not cancel
- printing of the rest of the documents. }
-
- PROCEDURE TApplication.SFGetParms(itsCmdNumber: CmdNumber;
- VAR dlgID: INTEGER;
- VAR where: Point;
- VAR fileFilter, dlgHook, filterProc: ProcPtr;
- typeList: TypeListHandle);
- { Called to return all the parameters that should be passed to SFGetFile; when
- called, typeList is a valid handle to a 0-length block. Defaults to
- dlgID = getDlgID;
- where = (100, 100);
- fileFilter = NIL;
- dlgHook = NIL;
- filterProc = NIL;
- typeList = list of just the main file type supported by the application. (If type
- list ends up with nothing in it, then all file types are supported. }
-
- { Termination }
- PROCEDURE TApplication.Close;
- { Called when the user chooses Quit from the menu, and tries to save all the open
- documents. If all succeed the application terminates. Signals Failure with error =
- noErr and message = msgCancelled if user cancels }
-
- { Hierarchy }
- PROCEDURE TApplication.AddDocument(aNewDocument: TDocument);
- { Add another document to my list of documents, and make it the current one }
-
- PROCEDURE TApplication.AddFreeWindow(aWindow: TWindow);
- { Add the window to the free-window list }
-
- PROCEDURE TApplication.DeleteDocument(docToDelete: TDocument);
- { Delete a document from my list of documents }
-
- PROCEDURE TApplication.DeleteFreeWindow(windowToDelete: TWindow);
- { Delete a window from my list of free windows }
-
- PROCEDURE TApplication.EachFreeWindow(PROCEDURE
- DoToWindow(aWindow: TWindow));
- { Perform DoToWindow on each TWindow object in the list gFreeWindowList }
-
- PROCEDURE TApplication.ForAllDocumentsDo(PROCEDURE
- DoToDoc(aDocument: TDocument));
- { Perform the given procedure on all open documents currently owned by the
- application }
-
- PROCEDURE TApplication.ForAllWindowsDo(PROCEDURE
- DoToWind(aWindow: TWindow));
- { Perform the given procedure on all windows known to the application, both
- document and free windows. }
-
- { Window Manager Windows }
- PROCEDURE TApplication.SelectWMgrWindow(aWMgrWindow: WindowPtr);
- { "Selects" aWMgrWindow by calling the toolbox routine SelectWindow. When any window
- is selected, it goes through here. We never call SelectWindow directly.}
-
- FUNCTION TApplication.GetRsrcWindow(storage: Ptr;
- rsrcId: INTEGER;
- VAR isResizable,
- isClosable: BOOLEAN): WindowPtr;
- { Get a Window Manger window resource whose resource id is rsrId. Return isResizable
- and isClosable based upon the 'WIND' resource. }
-
- FUNCTION TApplication.WMgrToWindow(aWMgrWindow: WindowPtr): TWindow;
- { Returns the window object that represents the given Window Manager window, or NIL
- if there is no window object. }
-
- { Idle Events }
- PROCEDURE TApplication.Idle(phase: IdlePhase);
- { Parcels out idle time to the DoIdle method in the target and cohandler chains of
- TEvtHandlers. If your application needs to do something at idle time then override
- DoIdle instead of this method. }
-
- { Cursor }
- FUNCTION TApplication.TrackCursor: BOOLEAN;
- { Returns true if the cursor is set by a view. Otherwise the cursor is set to an
- arrow and TrackCursor returns false.}
-
- { Keyboard events }
- FUNCTION TApplication.DoKeyCommand(ch: Char;
- aKeyCode: INTEGER;
- VAR info: EventInfo): TCommand; OVERRIDE;
- { Handle keydown events. }
-
- { Menu Events }
- FUNCTION TApplication.DoCommandKey(ch: Char;
- VAR info: EventInfo): TCommand; OVERRIDE;
- { Called when a keyDown event is received and the command key is down. }
-
- FUNCTION TApplication.MenuEvent(menuItem: LONGINT): TCommand;
- { Given a value returned by MenuKey or MenuSelect, figure out the command number that
- was chosen, have the application create a command object, and return it. }
-
- PROCEDURE TApplication.SetUndoText(cmdDone: BOOLEAN;
- aCmdNumber: CmdNumber);
- { Called to setup the Undo menu item; if cmdDone is TRUE it reads Undo, otherwise it
- reads Redo. aCmdNumber indicates the command that goes after the Undo/Redo. }
-
- PROCEDURE TApplication.SetupTheMenus;
- { Initiates the process of enabling & checking menu items. }
-
- { Opening and Closing Windows }
- PROCEDURE TApplication.CloseWMgrWindow(aWMgrWindow: WindowPtr);
- { Called when user closes a window either with a menu item or with a GoAway box.
- Signals Failure with error = noErr and message = msgCancelled if user cancels }
-
- { Command Management }
- PROCEDURE TApplication.CommitLastCommand; OVERRIDE;
- { Commits the last command by calling its Commit method. }
-
- FUNCTION TApplication.GetLastCommand: TCommand; OVERRIDE;
- { Returns the last undoable command. The command returned is not yet committed.}
-
- FUNCTION TApplication.GetNextCommand: TCommand; OVERRIDE;
- { Returns a previously posted command. Nil if there are no queued commands.}
-
- PROCEDURE TApplication.PerformCommand(command: TCommand); OVERRIDE;
- { Performs the given command taking care of UNDO/REDO and clipboard related details.
- Tracks the command first, if necessary.
- This DOES NOT check to see if command is NIL. }
-
- PROCEDURE TApplication.PostCommand(command: TCommand); OVERRIDE;
- { Called to post a command to the queue for later execution. }
-
- { Double/Triple Clicks }
- FUNCTION TApplication.CountClicks(aPDownEvent: EventRecordPtr;
- whereMouseDown: INTEGER): INTEGER;
- { Called by TApplication.HandleMouseDown. Returns the number of clicks that can be
- considered multiple clicks (e.g. if it returns 1 the mouse down should be treated
- as a single click, or possibly the first click of a multi-click sequence. If it
- returns 2 the click should be considered a double-click, etc. A click is considered
- part of a multi-click sequence if the mouse down was within the proper time range
- of the previous mouse up, and was within the proper number of pixels of the last
- mouse down. TApplication.HandleMouseDown sets theClickCount of its EventInfo record
- to the result of this function. aPDownEvent is a pointer to the mouse down event.
- whereMouseDown is the result of FindWindow on the event. }
-
- { Command Handlers }
- FUNCTION TApplication.DoMenuCommand(aCmdNumber: CmdNumber): TCommand; OVERRIDE;
- { Handles the application specific menu commands. }
-
- PROCEDURE TApplication.DoSetupMenus; OVERRIDE;
-
- { Clipboard stuff }
-
- PROCEDURE TApplication.AbandonUndoClipboard;
- { Called when the undo clipboard is no longer needed. Calls
- gClipUndoView.FreeFromClipboard and sets gClipUndoView to NIL. }
-
- PROCEDURE TApplication.AboutToLoseControl(convertClipboard: BOOLEAN);
- { Called when about to activate a Desk Accessory, switch out to another application,
- or Terminate. convertClipboard is generally true, except it will be FALSE if we get
- a Swticher event that does not require Clipboard conversion }
-
- PROCEDURE TApplication.AbsorbScrapStuff;
- { Called to retrieve the current InfoScrap record from low memory. This will be used
- to determine if the scrap has changed. }
-
- PROCEDURE TApplication.CheckDeskScrap;
- { Checks to see if the desk scrap has changed by calling AbsorbScrapStuff and
- comparing the current scrap change count with the previous change count. If the
- scrap has changed, then the current clipboard becomes the undo clipboard and
- ReadFromDeskScrap is called to read in the new desk scrap. }
-
- PROCEDURE TApplication.ClaimClipboard(clipView: TView);
- { Makes clipView the new view displayed by the Clipboard. Typically called by a Cut
- or Copy command. }
-
- FUNCTION TApplication.GetDataToPaste(aDataHandle: Handle;
- VAR dataType: ResType): LONGINT;
- { Returns the number of bytes in the paste data. Will signal Failure if it gets an
- error. }
-
- PROCEDURE TApplication.LaunchClipboard;
- { Called by TApplication.Run, before the main event loop. }
-
- FUNCTION TApplication.MakeClipboardWindow: TWindow;
- { Called by TApplication.IApplication to make the clipboard window and associated
- frame(s). clipView is the view to be initially installed in the clipboard--it is
- gClipOrphanage. }
-
- PROCEDURE TApplication.ReadFromDeskScrap;
- { Called at launch and when the desk scrap changes. Calls
- TApplication.MakeViewForAlienClipboard, then ClaimClipboard }
-
- FUNCTION TApplication.MakeViewForAlienClipboard: TView;
- { Returns gClipOrphanage, which is capable of displaying scrap of type TEXT or PICT.
- Override this to create a view to handle other types of scrap data. }
-
- PROCEDURE TApplication.RegainControl(checkClipboard: BOOLEAN);
- { Called when switching in or when leaving a desk accessory }
-
- PROCEDURE TApplication.SetClipView(clipView: TView);
- { Installs the given view into the clipboard window. }
-
- PROCEDURE TApplication.SwapClipViews;
- { Swaps the undo clipboard view with the current clipboard view. Used during an Undo
- or Redo. }
-
- { Debugging }
- PROCEDURE TApplication.IdentifySoftware; OVERRIDE;
- { Writes out to the debug window the current version of MacApp® , UObject and UDebug.
- }
-
- { Error Alerts }
-
- PROCEDURE TApplication.Beep(duration: INTEGER);
- { Call this method when you want to beep at the user. Sound manager users may have to
- override this method to integrate its functionality in with your application }
-
- PROCEDURE TApplication.ShowError(error: OSerr;
- message: LONGINT);
- { Calls ErrorAlert to display an error alert. }
-
- PROCEDURE TApplication.SpaceIsLow;
- { Called when space is low, at intervals of kLowSpaceInterval ticks. Displays an
- alerting informing the user that memory space is low. Override this if you wish to
- take more appropriate action. }
-
- { Miscellaneous }
-
- PROCEDURE TApplication.DoShowAboutApp;
- { Called to show the "About the App" information }
-
- PROCEDURE TApplication.InvalidateFocus;
- { Called to indicate that a view is unfocused when you don't know which view
- was focused. }
-
- PROCEDURE TApplication.InvalidateCursorRgn;
- { Indicates that the cursor rgn that is used to determine when MultiFinder™ should
- wake up your application and tell you the mouse moved is invalid and must be
- recomputed. When not using MultiFinder™ the region is used to determine when to
- give all the subviews a chance to set the cursor. }
-
- PROCEDURE TApplication.ActivateBusyCursor(entering: BOOLEAN);
- { Called when the busy cursor mechanism should be activated or deactivated. }
-
- END;
-
- {--------------------------------------------------------------------------------------------------}
- TDocument = OBJECT (TEvtHandler) { Corresponds to a Finder document. Manages
- document data in files and in main memory.
- }
- fWindowList: TList; { list of windows belonging to this document
- }
- fViewList: TList; { list of views belonging to document }
- fDocPrintHandler: TPrintHandler; { the object to be told to PRINT or
- DoSetUpMenus when 'Print', 'Print One', or
- 'Page Setup…' is selected from the menu
- while this is the active document. }
-
- fChangeCount: LONGINT; { master count of changes since last Save }
- fSavePrintInfo: BOOLEAN; { if TRUE for a document saved on disk, the
- 'print info' record of the
- fDocPrintHandler will be written out to
- the data fork before other writing takes
- place }
- fSharePrintInfo: BOOLEAN; { if TRUE, then all printHandlers associated
- with views belonging to the same document
- will share the same 'print info' record }
- fPrintInfo: Handle; { if non-NIL, this is a handle to a 120-byte
- 'print info' record }
-
- fTitle: StringHandle; { file name }
- fFileType: OSType; { file type }
- fCreator: OSType; { creator ID }
- fVolRefNum: INTEGER; { volume refNum }
- fModDate: LONGINT; { file mod date when last read/saved }
- fReopenAlert: BOOLEAN; { whether to give an alert if user reopens
- doc }
- fSaveExists: BOOLEAN; { whether a disk file representing this
- document exists }
- fCommitOnSave: BOOLEAN; { commit the last command before saving the
- document, if it affected the document.
- This defaults to TRUE, but carefully
- written applications could set this FALSE.
- }
- fUsesDataFork: BOOLEAN; { whether the document uses the data fork of
- the file }
- fUsesRsrcFork: BOOLEAN; { whether the document uses the rsrc fork of
- the file }
- fDataOpen: BOOLEAN; { whether the data fork should be open all
- the time }
- fRsrcOpen: BOOLEAN; { whether the resources fork be open all the
- time }
- fDataPerm: INTEGER; { permission to use for reading data fork }
- fRsrcPerm: INTEGER; { permission to use for reading the rsrc
- fork }
- fDataRefnum: INTEGER; { refnum; valid only if data fork is left
- open }
- fRsrcRefnum: INTEGER; { refnum; valid only if resource fork is
- left open }
- { these will be -1 if the fork is
- not open or if the corresponding
- fXXXOpen flag is FALSE }
- fSaveInPlace: SIPChoice; { how to save files in place (if desired) }
-
- { Init & Free }
- PROCEDURE TDocument.IDocument(itsFileType, itsCreator: OSType;
- usesDataFork, usesRsrcFork: BOOLEAN;
- keepsDataOpen, keepsRsrcOpen: BOOLEAN);
- { Initialization method for TDocument. }
-
- PROCEDURE TDocument.Free; OVERRIDE;
- { This does not call FreeData by default, since you may need to control the order in
- which things are freed. Your override of TDocument.Free can call FreeData if
- convenient. }
-
- PROCEDURE TDocument.FreeData;
- { Called when a document is reverted, in order to free it's data objects. You may
- also wish to call this from you document's Free method, if convenient. }
-
- PROCEDURE TDocument.FreeFromClipboard;
- { Called to free a Clipboard document.Simply calls Free. }
-
- PROCEDURE TDocument.GetInspectorName(VAR inspectorName: Str255); OVERRIDE;
- { Called by the Inspector to get the name of this class. }
-
- PROCEDURE TDocument.Fields(PROCEDURE
- DoToField(fieldName: Str255;
- fieldAddr: Ptr;
- fieldType: INTEGER)); OVERRIDE;
- { Called by the Inspector and the Debugger to display the contents of this class's
- fields. }
-
- { Opening / Printing Documents }
- PROCEDURE TDocument.DoInitialState;
- { Called for 'New', 'Revert' to blank, Open Tool. Default is to do nothing; You may
- need to do further initialization that you would not do in case of an Open… }
-
- PROCEDURE TDocument.DoMakeWindows;
- { Should take the views created by DoMakeViews and create windows and frames to
- display them. }
-
- PROCEDURE TDocument.DoMakeViews(forPrinting: BOOLEAN);
- { Create all necessary views for this document (based on forPrinting flag) and store
- into fields of your document. The document will then be sent either DoMakeWindows
- or Print. }
-
- PROCEDURE TDocument.DoRead(aRefNum: INTEGER;
- rsrcExists, forPrinting: BOOLEAN);
- { rsrcExists indicates whether the document has a resource fork opened or not; it is
- FALSE if fUsesRsrcFork is FALSE. makingCopy indicates whether this save is for
- making a copy of the document (vs. a regular Save or Save As…); disk-based
- documents (especially) might optimize their behavior if this is TRUE. The default
- behaviour is to just read the printinfo from the document's data-fork (useful huh?)
- }
-
- PROCEDURE TDocument.DoWrite(aRefNum: INTEGER;
- makingCopy: BOOLEAN);
- { rsrcExists indicates whether the document has a resource fork opened or not; it is
- FALSE if fUsesRsrcFork is FALSE. makingCopy indicates whether this save is for
- making a copy of the document (vs. a regular Save or Save As…); disk-based
- documents (especially) might optimize their behavior if this is TRUE. The default
- behaviour is to just write the printinfo to the document's data-fork (useful huh?)}
-
- FUNCTION TDocument.HandlesPrintingCommands: BOOLEAN; OVERRIDE;
- { By defualt returns FALSE. }
-
- FUNCTION TDocument.OpenAFile(name: Str255;
- volRefnum: INTEGER;
- openData, openRsrc: BOOLEAN;
- dataPerm, rsrcPerm: INTEGER;
- VAR dataRefnum, rsrcRefnum: INTEGER): OSerr;
- { Called from ReadFromFile to open the document's data and/or resource forks.}
-
- PROCEDURE TDocument.OpenAgain(itsCmdNumber: CmdNumber;
- openingDoc: TDocument);
- { Called if the user tries to open the same document twice. openingDoc will be the
- document object being opened. Default brings SELF to the front and calls
- Failure(noErr, 0), which will abort opening the document. (The goal is to prevent
- the user from having 2 copies of the same document open, in which case they could
- make incompatible changes to both.) You might override this if you want to open a
- second window on the same document. In the ideal case, you should make both windows
- display exactly the same data, and changes made to one should be reflected in the
- other. You could also override this to create a read-only copy of the document. }
-
- PROCEDURE TDocument.ReadFromFile(VAR anAppFile: AppFile;
- forPrinting: BOOLEAN);
- { Called to read an existing file for display or printing. If anAppFile.fName = ''
- THEN we read from the file specified in the instance variables instead of the
- parameter, and the parameter will be updated to match the document. }
-
- PROCEDURE TDocument.ShowWindows;
- { Called when opening the document initially; default is to call OpenWindow for all
- windows that have fFlags.openInitially TRUE }
-
- PROCEDURE TDocument.UntitledName(VAR noName: Str255);
- { Called to supply a name for an untitled document. If this returns '' then the
- windows are not renamed from the value specified in their titles. }
-
- { Saving Documents }
- PROCEDURE TDocument.AboutToSave(itsCmd: CmdNumber;
- VAR newName: Str255;
- VAR newVolRefnum: INTEGER;
- VAR makingCopy: BOOLEAN);
- { Called right after the SFPutFile (if any) and before deciding between SaveViaTemp &
- SaveInPlave. Applications can use the name in an alert and/or modify the makingCopy
- parameter if they do not want to have the document renamed. }
-
- PROCEDURE TDocument.DoNeedDiskSpace(VAR dataForkBytes, rsrcForkBytes: LONGINT);
- { Bytes required to store SAVE file(s) on disk. When called, both parameters are set
- to 0 for you. }
-
- PROCEDURE TDocument.FreeFile;
- { Called to free in memory data associated with the currently opened document. The
- default is to call CloseFile(fDataRefnum, fRsrcRefnum) if fDataOpen OR fRsrcOpen. }
-
- FUNCTION TDocument.GetSaveInfo(itsCmdNumber: CmdNumber;
- copyFInfo: BOOLEAN;
- VAR cInfo: CInfoPBRec): BOOLEAN;
- { Called to get the desired file info for saving the file. Default copies the info
- from the current file if fSaveExists AND copyFInfo, otherwise it just sets the file
- type and creator based on the fields of SELF. If an error occurs calling the file
- system, the cInfo record will not be filled in. Returns TRUE if it successfully
- gets the info from the file. }
-
- PROCEDURE TDocument.GetTempName(VAR fileName: Str255);
- { Return a temporary name for saving the file. The filename is constructed in two
- parts: the first part is the document's name, or the application's name if the
- document is untitled. The second part, appended to the first part, is a pseudo-
- random number based on the tick count and number of seconds since boot. }
-
- PROCEDURE TDocument.MakeNewCopy(makingCopy: BOOLEAN;
- validFInfo: BOOLEAN;
- VAR cInfo: CInfoPBRec);
- { Creates a brand new copy of the document in the file specified by cInfo. The name,
- volume refnum, file type, and creator must be specified in cInfo. The other info
- fields of cInfo are used only if makingCopy is FALSE. makingCopy is TRUE if this
- save is making a copy of the document (vs. a regular Save or Save As…) Caller is
- responsible for calling FlushVol after this. }
-
- FUNCTION TDocument.PoseSaveDialog: INTEGER;
- { If the document has been changed (fChangeCount > 0), then the user is asked to save
- the document. PoseSaveDialog returns cancel, kYesButton or kNoButton, depending on
- the button chosen by the user. If the document has not been changed then kNoButton
- is returned. }
-
- PROCEDURE TDocument.RequestFileName(itsCmdNumber: CmdNumber;
- makingCopy: BOOLEAN;
- VAR fileName: Str255;
- VAR volRefnum: INTEGER);
- { Asks the user for a filename for the document. Calls TDocument.SFPutParms and then
- SFPPutFile. Fails if the user clicks the Cancel button to end the put file dialog.
- }
-
- FUNCTION TDocument.GetChangeCount: LONGINT;
- { Gets the document change count }
-
- PROCEDURE TDocument.SetChangeCount(newChangeCount: LONGINT);
- { Sets the document change count }
-
- PROCEDURE TDocument.Save(itsCmdNumber: CmdNumber;
- askForFilename, makingCopy: BOOLEAN);
- { Try to save the document to disk; If askForFilename, put up a Std File box; If
- makingCopy, then this is for the Save a Copy In command, so we do not rename the
- document. This method calls FlushVol (which takes care of the requirements of
- MakeNewCopy, SaveInPlace, and SaveViaTemp. }
-
- PROCEDURE TDocument.SaveAgain(itsCmdNumber: CmdNumber;
- makingCopy: BOOLEAN;
- savingDoc: TDocument);
- { Called when the user tries to Save As… or Save a Copy In… and specifies the name of
- a document that is already opened. The default case calls Failure(errSaveAgain,
- msgSaveFailed) to display an error. (The goal is to prevent the user from having 2
- copies of the same document open, in which case they might make incompatible
- changes to both copies.) savingDoc is the document being saved }
-
- PROCEDURE TDocument.SavedOn(VAR fileName: Str255;
- volRefnum: INTEGER);
- { Called when a save successfully completes and we are switching to the new file
- (ie., not a Save a Copy In…). }
-
- PROCEDURE TDocument.SaveInPlace(itsCmdNumber: CmdNumber;
- makingCopy, copyFInfo: BOOLEAN;
- VAR fileName: Str255;
- volRefnum: INTEGER);
- { Called to save a document in place. Default is to delete the existing file if NOT
- (fDataOpen OR fRsrcOpen). If you have disk based document, you have to decide
- whether to allow saving in place. makingCopy is TRUE if this save is making a copy
- of the document (vs. a regular Save or Save As…) copyFInfo is TRUE if the file
- information should be copied to the new file Caller is responsible for calling
- FlushVol after this. }
-
- PROCEDURE TDocument.SaveViaTemp(itsCmdNumber: CmdNumber;
- makingCopy, copyFInfo: BOOLEAN;
- VAR fileName: Str255;
- volRefnum: INTEGER);
- { Called to save the document by creating a temporary copy of the file and renaming
- it. MacApp uses this method except when there is not enough disk space available.
- makingCopy is TRUE if this save is making a copy of the document (vs. a regular
- Save or Save As…) copyFInfo is TRUE if the file information should be copied to the
- new file Caller is responsible for calling FlushVol after this. }
-
- PROCEDURE TDocument.SFPutParms(itsCmdNumber: CmdNumber;
- VAR dlgID: INTEGER;
- VAR where: Point;
- VAR defaultName, prompt: Str255;
- VAR dlgHook, filterProc: ProcPtr);
- { Called to return all the parameters that should be passed to
- SFPutFile. Defaults to
- dlgID = putDlgID;
- where = (100, 100);
- defaultName not changed;
- prompt gotten from resource file;
- dlgHook = NIL;
- filterProc = NIL. }
-
- { Closing Documents }
- PROCEDURE TDocument.Close;
- { Close a document and free it. Signals Failure with error = noErr and message =
- msgCancelled if user cancels. ??? NOTE: Must never be called for a document related
- to a view in the Clipboard. }
-
- { Revert }
- PROCEDURE TDocument.Revert;
- { IF fSaveExists is TRUE then reverts to the file saved on disk, otherwise merely
- resets the print handler and calls doInitialState. Calls FreeData to free any
- existing data and commits any currently active command. }
-
- PROCEDURE TDocument.Abandon;
- { Called when a document is closed and changes are being abandoned. For memory based
- documents the default behaviour of doing nothing is OK. For disk based documents that
- change the original copy this is the place to override to put back the original
- contents if you still have it available somewhere (a scratch file?) }
-
- PROCEDURE TDocument.ShowReverted;
- { Called after Revert to show brand new document; default tells each view to
- ShowReverted }
-
- { Miscellaneous }
- PROCEDURE TDocument.CheckDiskFile(rsrcId, rsrcIndex: INTEGER;
- reverting: BOOLEAN);
- { Check to see if the disk file has changed. If so put up alert phFileChanged after
- setting ^0 to fTitle and ^1 to the string specified by the rsrcId and rsrcIndex. If
- user cancels, signal Failure(noErr, msgCancelled). If reverting is TRUE, then I/O
- errors and nonmatching file types will cause a Failure. Otherwise, this is a Save
- and any I/O errors and nonmatching file type will be ignored. }
-
- FUNCTION TDocument.DiskFileChanged(checkType: BOOLEAN): OSerr;
- { Returns noErr if fSaveExists is FALSE or if the file's modification date matches
- fModDate. If checkType is TRUE then returns errFTypeChanged if the file type has
- changed. If the file exists but with a different modification date, returns
- errFileChanged. }
-
- PROCEDURE TDocument.SetTitle(aTitle: Str255);
- { Sets SELF.fTitle to aTitle and calls SetTitleForDoc for each window of the
- document. }
-
- { Command Handlers }
- FUNCTION TDocument.DoMenuCommand(aCmdNumber: CmdNumber): TCommand; OVERRIDE;
- { Handles the default menu commands associated with a document and must be overridden
- to handle any additional items. }
-
- PROCEDURE TDocument.DoSetupMenus; OVERRIDE;
- { Setup the documents menus, this handles the default menus and must be overridden
- for any additional items. }
-
- { Hierarchy }
- PROCEDURE TDocument.AddView(aView: TView);
- { Adds the view to the end of the document's view list. }
-
- PROCEDURE TDocument.AddWindow(aWindow: TWindow);
- { Adds the window to the end of the document's window list. }
-
- PROCEDURE TDocument.CloseView(aView: TView);
- { Called to close a view or window associated with a document.
- Document gets to decide whether to really close the view or not and whether to
- close itself or not. Does nothing if the view is not associated with the doc. }
-
- PROCEDURE TDocument.DeleteView(viewToDelete: TView);
- { Deletes the view from the document's view list. }
-
- PROCEDURE TDocument.DeleteWindow(windowToDelete: TWindow);
- { Deletes the window from the document's window list. }
-
- PROCEDURE TDocument.ForAllViewsDo(PROCEDURE
- DoToView(aView: TView));
- { Performs DoToView on every view in every window belonging to the document. If you
- want to deal with all views belonging to the document use fViewList.Each. }
-
- PROCEDURE TDocument.ForAllWindowsDo(PROCEDURE
- DoToWind(aWindow: TWindow));
- { Perform the supplied proc to each window belonging to the document }
-
- END;
-
- {--------------------------------------------------------------------------------------------------}
- ViewTemplateSelector = (ViewType, ViewIncludeAt); { So C++ unions can have names }
- ViewTemplate = PACKED RECORD
- itsParentID: IDType;
- thisViewID: IDType;
- itsLocation: VPoint;
- itsSize: VPoint;
- itsVSizeDet: SizeDeterminer;
- itsHSizeDet: SizeDeterminer;
- isShown: BOOLEAN;
- isEnabled: BOOLEAN;
- filler: Byte;
- itsSignature: IDType; { Resource signature }
- CASE ViewTemplateSelector OF
- ViewType:
- (itsType: Str255); { Actually variable length }
- ViewIncludeAt:
- (includeRsrcID: INTEGER;
- itsSubViewOffset: VPoint);
- END;
- ViewTemplatePtr = ^ViewTemplate;
-
- ViewResource = RECORD
- numViews: INTEGER;
- theViews: ViewTemplate; { Actually, open-ended }
- END;
- ViewRsrcPtr = ^ViewResource;
- ViewRsrcHandle = ^ViewRsrcPtr; { Preferred }
- ViewRsrcHndl = ViewRsrcHandle; { Left in for compatibility (2.0) }
-
- {--------------------------------------------------------------------------------------------------}
- { Set by GetFocus; used by SetFocus. GetFocus/SetFocus are used to save and restore the focus
- behind MacApp's back. One use is to speed up scrolling (see TScroller). }
- {$IFC qExperimentalAndUnsupported}
- FocusRec = RECORD
- printing: BOOLEAN;
- drawingPictScrap: BOOLEAN;
- drawingPictScrapView: TView;
- focusedView: TView;
- longOffset: VPoint;
- org: Point;
- port: GrafPtr;
- clip: RgnHandle;
- isValid: BOOLEAN; { TRUE if FocusRec is valid }
- END;
- {$EndC}
-
- {--------------------------------------------------------------------------------------------------}
- TView = OBJECT (TEvtHandler) { Renders an image of a document or other
- data, and identifies mouse-clicked
- objects. }
- fSuperView: TView; { the current superview }
- fSubViews: TList; { subviews of this view }
- fDocument: TDocument; { the associated document if any. }
- fLocation: VPoint; { the location in superview coordinates }
- fSize: VPoint; { the size of this view }
- fSizeDeterminer: ARRAY [VHSelect] OF SizeDeterminer; { how this view's size is to
- be determined }
- fHLDesired: HLState; { the hilighting that is desired for this
- view }
- fIdentifier: IDType; { the ID if any }
- fShown: BOOLEAN; { is this view to be shown }
- fViewEnabled: BOOLEAN; { is this view enabled. (does it take
- clicks/keystrokes }
- fPrintHandler: TPrintHandler; { the associated print handler if any. }
- {$IFC qExperimentalAndUnsupported}
- fFocusRec: FocusRec; { The cached focus information }
- {$EndC}
-
- { Creation/Destruction Methods }
-
- PROCEDURE TView.IView(itsDocument: TDocument;
- itsSuperView: TView;
- itsLocation: VPoint;
- itsSize: VPoint;
- itsHSizeDet, itsVSizeDet: SizeDeterminer);
- { Initializes a view procedurally. }
-
- PROCEDURE TView.IRes(itsDocument: TDocument;
- itsSuperView: TView;
- VAR itsParams: Ptr);
- { Initialize aview from a resource template. }
-
- PROCEDURE TView.WRes(theResource: ViewRsrcHndl;
- VAR itsParams: Ptr);
- { For writing a view out to a resource. }
-
- PROCEDURE TView.WriteRes(theResource: ViewRsrcHndl;
- VAR itsParams: Ptr);
- { For writing a view to a resource works in conjunction with tbe previous method. }
-
- PROCEDURE TView.Free; OVERRIDE;
- { Frees its subviews, then if its superview is not NIL removes itself from the
- superviews list of subviews and if its document is not NIL removes itself from the
- documents list of views. If it has a print handler then it frees it, then calls
- inherited Free. }
-
- PROCEDURE TView.FreeFromClipboard;
- { If its document is not NIL then calls the document's FreeFromClipboard method,
- otherwise calls Free. }
-
- { Coordinate Conversion Methods }
-
- PROCEDURE TView.QDToViewPt(qdPoint: Point;
- VAR viewPt: VPoint);
- { Convert a Quickdraw point to a view point. }
-
- PROCEDURE TView.QDToViewRect(qdRect: Rect;
- VAR viewRect: VRect);
- { Convert a Quickdraw rect to a view rect. }
-
- FUNCTION TView.ViewToQDPt(viewPt: VPoint): Point;
- { Convert a view point to a QuickDraw point. }
-
- PROCEDURE TView.ViewToQDRect(viewRect: VRect;
- VAR qdRect: Rect);
- { Convert a view rect to a Quickdraw rect. }
-
- PROCEDURE TView.LocalToSuper(VAR thePoint: VPoint);
- { Given a point in local view coordinates, returns the same point in its superview's
- coordinate system.}
-
- PROCEDURE TView.SuperToLocal(VAR thePoint: VPoint);
- { Given a point in superview coordinates, returns the same point in the view's own
- coordinate system. }
-
- PROCEDURE TView.LocalToWindow(VAR thePoint: VPoint);
- { Given a point in local view coordinates, returns the same point in its window's (or
- most super superview's) coordinate system.}
-
- PROCEDURE TView.WindowToLocal(VAR thePoint: VPoint);
- { Given a point in window (or most super superview) coordinates, returns the same
- point in the view's own coordinate system. }
-
- { SubView Management Methods }
-
- PROCEDURE TView.EachSubView(PROCEDURE
- DoToSubView(theSubView: TView));
- { Iterate over all the views subviews passing each in turn to the procedure
- "DoToSubView". }
-
- FUNCTION TView.FirstSubViewThat(FUNCTION
- TestSubView(theSubView: TView): BOOLEAN): TView;
- { Iterate over this views subviews and return the first subview that meets
- 'TestSubView'. }
-
- FUNCTION TView.LastSubViewThat(FUNCTION
- TestSubView(theSubView: TView): BOOLEAN): TView;
- { Iterate over this views subviews and return the last subview that meets
- "TestSubView". }
-
- PROCEDURE TView.AddSubView(theSubView: TView);
- { Add 'theSubView' to our list of subviews. }
-
- PROCEDURE TView.RemoveSubView(theSubView: TView);
- { Remove 'theSubView' from our list of subviews. }
-
- PROCEDURE TView.MakeFirstSubView(theSubView: TView);
- { Make 'theSubView ' the first subview in our list. }
-
- PROCEDURE TView.MakeLastSubView(theSubView: TView);
- { Make 'theSubView' the last subview in our list. }
-
- FUNCTION TView.CountSubViews: INTEGER;
- { Return the number of subviews in our view. }
-
- FUNCTION TView.FindSubView(itsIdentifier: IDType): TView;
- { Find subview with identifier 'itsIdentifier' in our list of subviews. }
-
- { Open/Close/Activate Methods }
-
- PROCEDURE TView.Activate(entering: BOOLEAN);
- { Focuses and then highlights any current selection before calling all its subviews
- to activate themselves. }
-
- PROCEDURE TView.Open;
- { Calls each of its subviews to Open themselves. }
-
- PROCEDURE TView.Close;
- { Commits the last command before calling each of its subviews to Close themselves. }
-
- PROCEDURE TView.BeInScroller(itsScroller: TScroller);
- { If 'itsScroller' is not NIL then sets its scroll limits to its fSize. }
-
- PROCEDURE TView.BeInPort(itsPort: GrafPtr);
- { If its print handler is not NIL, calls DoCheckPrinter. Then calls each of its
- subviews to BeInPort. }
-
- PROCEDURE TView.ShowReverted;
- { First calls AdjustSize before forcing a redraw of the view, then call ShowReverted
- for each of its subviews. }
-
- { Choice Handling Methods }
-
- PROCEDURE TView.DoChoice(origView: TView;
- itsChoice: INTEGER); OVERRIDE;
- { If its superview is not NIL calls its DoChoice method. }
-
- { Size Methods }
-
- PROCEDURE TView.AdjustSize;
- { Calls ComputeSize, if the size has changed resizes itself and then calls
- DoPagination so that any page breaks can be recalculated. }
-
- PROCEDURE TView.CalcMinSize(VAR minSize: VPoint);
- { Calculate the minimum size of SELF. }
-
- PROCEDURE TView.ComputeSize(VAR newSize: VPoint);
- { Called by MacApp® to get the size of the view computed. }
-
- PROCEDURE TView.Resize(width, height: VCoordinate;
- invalidate: BOOLEAN);
- { Resizes SELF to 'width' & 'height', and forces an invalidation if 'invalidate' is
- TRUE. }
-
- PROCEDURE TView.SuperViewChangedSize(delta: VPoint;
- invalidate: BOOLEAN);
- { Called when our superview changes size. }
-
- PROCEDURE TView.SubViewChangedSize(theSubView: TView;
- delta: VPoint);
- { Called when one of our subviews changes size. }
-
- { Location Methods }
-
- PROCEDURE TView.Locate(h, v: VCoordinate;
- invalidate: BOOLEAN);
- { Moves our view to coordinate 'h' & 'v' invalidating if 'invalidate' is TRUE. }
-
- PROCEDURE TView.SubViewMoved(theSubView: TView);
- { Called when a subview is moved. }
-
- PROCEDURE TView.SuperViewMoved(invalidate: BOOLEAN);
- { Called when our superview is moved. }
-
- { Focusing Methods }
-
- FUNCTION TView.Focus: BOOLEAN;
- { Attempts to set up the drawing environment for this view. That consists of port,
- origin, gLongOffset and clipping. Returns FALSE if not able to focus. One reason
- focus could fail is if no superview is able to supply a port (ie not in a window
- and not printing or drawing pict scrap). Focus will return true, however, if the
- drawing environment can be setup but none of the view is currently visible due to
- clipping or scrolling by a superview. This lets you assemble view hierarchies and
- manipulate views without showing them to the user, but requires that you test
- IsVisible if you MUST know if the view is in fact visible. (MacApp will never ask a
- view to draw unless it is visible) }
-
- FUNCTION TView.FocusOnSuperView: BOOLEAN;
- { Focuses on our superview. }
-
- PROCEDURE TView.InvalidateFocus;
- { Indicates that the view's focus is no longer valid and must be recomputed. }
-
- FUNCTION TView.IsFocused: BOOLEAN;
- { Check to see if we are currently focused. }
-
- PROCEDURE TView.ClipFurtherTo(r: Rect;
- hDeltaOrg, vDeltaOrg: INTEGER);
- { Set clipping to: (<current clipping> INTERSECT r) OFFSET-BY (hDeltaOrg, vDeltaOrg).
- }
-
- PROCEDURE TView.AssumeFocused;
- { Causes a ProgramBreak if the focused view isn't SELF }
-
- { Drawing Methods }
-
- {$IFC qExperimentalAndUnsupported}
- PROCEDURE TView.DoOffScreen(PROCEDURE WhatToDo);
- { The WhatToDo procedure is performed while focused "offscreen" and the results
- are blitted back on to the screen. }
- {$EndC}
-
- PROCEDURE TView.DrawContents;
- { Causes the views contents to be drawn and that of any of its subviews. }
-
- PROCEDURE TView.Draw(area: Rect);
- { Currently does nothing. Must be overridden. }
-
- PROCEDURE TView.DoHighlightSelection(fromHL, toHL: HLState);
- { Currently does nothing. Must be overridden. }
-
- PROCEDURE TView.Adorn(area: Rect;
- itsPenSize: Point;
- itsAdornment: CntlAdornment);
- { Handles the adornment of the view based on the CntlAdornment enumeration. }
-
- FUNCTION TView.HasPendingUpdate: BOOLEAN;
- { Returns TRUE if there is a pending update event for this view, FALSE if not. }
-
- PROCEDURE TView.Update;
- { If its window is not NIL then does an update by calling DrawContents. }
-
- { Validation/Invalidation Methods }
-
- PROCEDURE TView.ForceRedraw;
- { Invalidates the entire view forcing a redraw. }
-
- PROCEDURE TView.InvalidVRect(viewRect: VRect);
- { Invalidates a view rect. }
-
- PROCEDURE TView.ValidVRect(viewRect: VRect);
- { Converts 'viewRect' to a QD Rect then calls VisibleRect & ValidRect with the result. }
-
- PROCEDURE TView.InvalidRect(r: Rect);
- { Invalidates a Quickdraw rect. }
-
- PROCEDURE TView.RevealRect(rectToReveal: VRect;
- minToSee: Point;
- redraw: BOOLEAN);
- { Scrolls a rect in to view, with 'minToSee' being the point which will end up at the
- bottom of the view, i.e.the minimum amount to be seen and 'rectToReveal' the rect
- being scrolled. }
-
- PROCEDURE TView.RevealTop(redraw: BOOLEAN);
- { Scroll the top of a rect into view. }
-
- PROCEDURE TView.RevealBottom(redraw: BOOLEAN);
- { Scroll the bottom of a rect into view. }
-
- { Mouse Handling Methods }
-
- FUNCTION TView.ContainsMouse(theMouse: VPoint): BOOLEAN;
- { Is the view point 'theMouse' currently in our view. }
-
- FUNCTION TView.HandleMouseDown(theMouse: VPoint;
- VAR info: EventInfo;
- VAR hysteresis: Point;
- VAR theCommand: TCommand): BOOLEAN;
- { The method responsible for handling a mouse down in the view, calls DoMouseCommand
- to handle it. }
-
- FUNCTION TView.DoMouseCommand(VAR theMouse: Point;
- VAR info: EventInfo;
- VAR hysteresis: Point): TCommand;
- { Returns a simple tracker which by default calls back tracking methods of this view.
- There are two possibilities here:
- 1) Override DoMouseCommand to return commands that represent more complex, even
- undoable actions. That command may either let its tracking call back the view's
- tracking methods (the default) which must be overridden to do anything useful or it
- may simply do all the tracking itself. This mostly depends on whether different
- commands returned from the view would have different tracking behavior. For example
- this is the approach taken by DrawShapes.
- 2) Override the view's tracking methods and let the default tracker them. For example
- this is the approach taken by TControl. }
-
- { Cursor Handling Methods }
-
- FUNCTION TView.HandleCursor(theMouse: VPoint;
- cursorRgn: RgnHandle): TView;
- { Handles the setting of the cursor by calling our DoSetCursor method and the same
- For all our subviews. }
-
- FUNCTION TView.DoSetCursor(localPoint: Point;
- { By default merely returns FALSE. }
- cursorRgn: RgnHandle): BOOLEAN;
-
- PROCEDURE TView.GetDefaultCursorRgn(localPoint: Point;
- cursorRgn: RgnHandle);
- { Returns the largest appropriate cursor region, called by DoSetCursor. }
-
- { Miscellaneous Methods }
-
- FUNCTION TView.GetDialogView: TView; { actually, TDialogView… }
- { If our superview is not NIL then calls its GetDialogView method and returns the
- result, otherwise returns NIL. }
-
- FUNCTION TView.GetGrafPort: GrafPtr;
- { Returns a pointer to our Graf Port. }
-
- FUNCTION TView.GetScroller(immediateSuperView: BOOLEAN): TScroller;
- { Returns a reference to our scroller. }
-
- FUNCTION TView.GetWindow: TWindow;
- { Returns a reference to the window that we are in, if any. }
-
- PROCEDURE TView.GetExtent(VAR itsExtent: VRect);
- { Returns a view rect the size of our extent in 'itsExtent'. }
-
- PROCEDURE TView.GetQDExtent(VAR qdExtent: Rect);
- { Returns a Quickdraw rect the size of our extent in 'qdExtent'. }
-
- PROCEDURE TView.GetFrame(VAR itsFrame: VRect);
- { Returns in'itsFrame' a VRect that is the boundary of our view in superview
- coordinates. This is calculated by adding its size to its location. }
-
- PROCEDURE TView.GetVisibleRect(VAR visQDRect: Rect);
- { Retuns a Quickdraw rect the size of the visible amount of our view. }
-
- PROCEDURE TView.ViewEnable(state, redraw: BOOLEAN);
- { Enables & Redraws the view based on 'state' & 'redraw'. }
-
- FUNCTION TView.IsViewEnabled: BOOLEAN;
- { Checks to see if our view is currently enabled. }
-
- PROCEDURE TView.Show(state, redraw: BOOLEAN);
- { If 'state' is not fShown then set fShown to TRUE and call ForceRedraw if 'redraw'
- is TRUE. Otherwise invalidate our focus and set fShown to 'state'. }
-
- FUNCTION TView.IsShown: BOOLEAN;
- { Checks to see if our view is currently shown. }
-
- FUNCTION TView.IsVisible: BOOLEAN;
- { Returns TRUE if any portion of the view is currently visible when focused }
-
- { Clipboard Handling }
-
- FUNCTION TView.ContainsClipType(aType: ResType): BOOLEAN;
- { Checks to see if the clipboard contains the type 'aType'. }
-
- FUNCTION TView.GivePasteData(aDataHandle: Handle;
- dataType: ResType): LONGINT;
- { Gets the scrap data of the type 'dataType', returns any errors as function result. }
-
- PROCEDURE TView.WriteToDeskScrap;
- { Writes to desk scrap. }
-
- { PrintingMethods }
-
- PROCEDURE TView.AttachPrintHandler(itsPrintHandler: TPrintHandler);
- { Called by the PrintHandler during its initialization, NOT directly by you }
-
- FUNCTION TView.DoBreakFollowing(vhs: VHSelect;
- prevBreak: VCoordinate;
- VAR automatic: BOOLEAN): VCoordinate;
- { Returns the location of the page break which follows the page break located at
- 'prevBreak', in direction vhs; returns automatic = TRUE if the page-break is
- thought of as an 'automatic' rather than a 'manual' (user-specified) one. Note that
- page-breaks in dimension 'v' are drawn as vertical lines, those in dimension 'h' as
- horizontal lines }
-
- PROCEDURE TView.DoCalcPageStrips(VAR pageStrips: Point);
- { Computes the number of horizontal and vertical page strips. }
-
- PROCEDURE TView.DoCalcViewPerPage(VAR viewPerPage: VPoint);
- { Determine how much of the view normally goes into each printed page, in each
- dimension. }
-
- PROCEDURE TView.DoCheckPrinter;
- { Check whether printer (if relevant) has changed, and if so, take appropriate action
- }
-
- PROCEDURE TView.DoDrawPrintFeedback(area: Rect);
- { Draw page-breaks, page-numbers, view-borders, rulers, etc. }
-
- PROCEDURE TView.DoDrawPageBreak(vhs: VHSelect;
- whichBreak: INTEGER;
- loc: VCoordinate;
- automatic: BOOLEAN);
- { Draw one page break. }
-
- FUNCTION TView.DoMenuCommand(aCmdNumber: CmdNumber): TCommand; OVERRIDE;
- { Enables my fPrintHandler to handle commands }
-
- PROCEDURE TView.DoPagination;
- { Recompute the dividing lines between areas of the view which will be mapped into
- different printed pages }
-
- PROCEDURE TView.DoPrinterChanged;
- { The metrics relating to printer use have changed; absorb the information and react
- }
-
- PROCEDURE TView.DoSetPageOffset(coord: VPoint);
- { Only reimplement in very unusual circumstances involving Tall-UnAdjusted text
- printing etc. }
-
- PROCEDURE TView.DoSetupMenus; OVERRIDE;
- { Tells my PrintHandler to set up its menus }
-
- PROCEDURE TView.GetPrintExtent(VAR printExtent: VRect);
- { Returns the part of the view that is to be printed. The default is to return the
- view's extent. }
-
- PROCEDURE TView.PageInteriorChanged(newInterior: Rect);
- { Allows a view which is printable to react to the changing of the page-interior
- rectangle }
-
- { Inspecting Methods }
-
- PROCEDURE TView.Fields(PROCEDURE DoToField(fieldName: Str255;
- fieldAddr: Ptr;
- fieldType: INTEGER)); OVERRIDE;
- { Called by the Inspector and the Debugger to display the contents of this class's
- fields. }
-
- PROCEDURE TView.GetInspectorName(VAR inspectorName: Str255); OVERRIDE;
- { Called by the Inspector to get the name of this class. }
-
- { Tracking Methods }
-
- FUNCTION TView.IsDoneTracking: BOOLEAN;
- { Indicates whether the Tracker is through tracking. (the command is also through
- tracking if you return NIL from TrackMouse). Defaults to NOT StillDown.
- Most programs won't have to mess with this.
- NOTE you still have to deal with queued events if you change the criteria for TRUE. }
-
- PROCEDURE TView.TrackConstrain(anchorPoint, previousPoint: VPoint;
- VAR nextPoint: VPoint);
- { Override this if your Tracker calls back to the view (the Default) an you want to
- constrain the mouse point to a grid, force drawing a square, etc. This is called only
- if fConstrainsMouse is TRUE. }
-
- PROCEDURE TView.TrackFeedback(anchorPoint, nextPoint: VPoint;
- turnItOn, mouseDidMove: BOOLEAN);
- { Override this if your Tracker calls back to the view (the Default) an you want to
- display any tracking feedback }
-
- PROCEDURE TView.TrackMouse(aTrackPhase: TrackPhase;
- VAR anchorPoint, previousPoint, nextPoint: VPoint;
- mouseDidMove: BOOLEAN);
- { Override this if your Tracker calls back to the view (the Default) an you want to
- display any tracking feedback }
-
- END;
-
- {--------------------------------------------------------------------------------------------------}
- { Set by GetFocus; used by SetFocus. GetFocus/SetFocus are used to save and restore the focus
- behind MacApp's back. One use is to speed up scrolling (see TScroller). }
- {$IFC NOT qExperimentalAndUnsupported}
- FocusRec = RECORD
- printing: BOOLEAN;
- drawingPictScrap: BOOLEAN;
- drawingPictScrapView: TView;
- focusedView: TView;
- longOffset: VPoint;
- org: Point;
- port: GrafPtr;
- clip: RgnHandle;
- isValid: BOOLEAN; { TRUE if FocusRec is valid }
- END;
- {$EndC}
- {--------------------------------------------------------------------------------------------------}
- ScrollerTemplate = RECORD
- wantVSBar: BOOLEAN;
- wantHSBar: BOOLEAN;
- vertMax: LONGINT;
- horzMax: LONGINT;
- vScrollUnits: INTEGER;
- hScrollUnits: INTEGER;
- vConstrain: BOOLEAN;
- hConstrain: BOOLEAN;
- sBarOffsets: Rect;
- END;
- ScrollerTemplatePtr = ^ScrollerTemplate;
-
- TScroller = OBJECT (TView) { A view which can "scroll" its contents by
- translating coordinates. }
-
- fTranslation: VPoint; { the current amount of translation }
- fScrollLimit: VPoint; { the 'limit' of the subview that should be
- scrollable }
- fMaxTranslation: VPoint; { the derived maximum amount of translation
- taking into account the visible portion of
- the view. This keeps us from scrolling the
- bottom of a view to the top of a window }
- fScrollBars: ARRAY [VHSelect] OF TSScrollBar; { associated scroll bars if any
- }
- fScrollUnit: Point; { increment of scroll }
- fConstrain: ARRAY [VHSelect] OF BOOLEAN; { should scrolling be constrained
- to a multiple of my scrollunit }
- fSBarOffsets: VRect; { how much to offset the associated scroll
- bars from my bounds }
- fRespondsToFunctionKeys: BOOLEAN; { if it responds to PgUp/PgDn, etc. }
-
- { Creation/Destruction Methods }
-
- PROCEDURE TScroller.IScroller(itsSuperView: TView;
- itsLocation, itsSize: VPoint;
- itsHSizeDet, itsVSizeDet: SizeDeterminer;
- itsHorzMax, itsVertMax: VCoordinate;
- wantHorzSBar, wantVertSBar: BOOLEAN);
- { Called to initialize a scroller procedurally. }
-
- PROCEDURE TScroller.CreateScrollBar(itsDirection: VHSelect);
- { Called to create a scrollbar in 'itsDirection'. }
-
- PROCEDURE TScroller.IRes(itsDocument: TDocument;
- itsSuperView: TView;
- VAR itsParams: Ptr); OVERRIDE;
- { Initialize a scroller from a resource template. }
-
- PROCEDURE TScroller.CreateTemplateScrollBar(itsDirection: VHSelect);
- { Called to create a scrollbar in 'itsDirection' from a resource template. }
-
- PROCEDURE TScroller.WRes(theResource: ViewRsrcHndl;
- VAR itsParams: Ptr); OVERRIDE;
- { For writing a scroller view out to a resource. }
-
- PROCEDURE TScroller.WriteRes(theResource: ViewRsrcHndl;
- VAR itsParams: Ptr); OVERRIDE;
- { For writing a scroller to a resource, works in conjunction with tbe previous
- method. }
-
- PROCEDURE TScroller.Free; OVERRIDE;
- { If there are attached scrollbars frees them before calling inherited Free. }
-
- { SubView Management Methods }
-
- PROCEDURE TScroller.AddSubView(theSubView: TView); OVERRIDE;
- { Calls inherited AddSubView and then calls 'theSubView' to BeInScroller passing SELF
- as the scroller to be in. }
-
- PROCEDURE TScroller.RemoveSubView(theSubView: TView); OVERRIDE;
- { Calls BeInScroller with a parameter of NIL, for 'theSubView', before calling
- inherited RemoveSubView. }
-
- { Focusing Methods }
-
- FUNCTION TScroller.Focus: BOOLEAN; OVERRIDE;
- { Attempts to Focus the scroller by calling inherited Focus and setting the
- gLongOffset }
-
- PROCEDURE TScroller.ForceRedraw; OVERRIDE;
- { Invalidates the entire view forcing a redraw. }
-
- { Miscellaneous Methods }
-
- PROCEDURE TScroller.LocalToSuper(VAR thePoint: VPoint); OVERRIDE;
- { Given a point in local coordinates, returns the same point in its superview's
- coordinate system. }
-
- PROCEDURE TScroller.SuperToLocal(VAR thePoint: VPoint); OVERRIDE;
- { Given a point in superview coordinates, returns the same point in the view's own
- coordinate system. }
-
- PROCEDURE TScroller.GetExtent(VAR itsExtent: VRect); OVERRIDE;
- { Returns the extent of the scroller. }
-
- { Size Methods }
-
- PROCEDURE TScroller.Resize(width, height: VCoordinate;
- invalidate: BOOLEAN); OVERRIDE;
- { Resizes the scroller to 'width' & 'height', redrawing if 'invalidate' is TRUE. }
-
- { Location Methods }
-
- PROCEDURE TScroller.Locate(h, v: VCoordinate;
- invalidate: BOOLEAN); OVERRIDE;
- { Calls inherited Locate before calling AdjustScrollbars. }
-
- PROCEDURE TScroller.AdjustScrollBars(invalidate: BOOLEAN);
- { Resizes and re-Locates the scrollbars if required. }
-
- PROCEDURE TScroller.SubViewChangedSize(theSubView: TView;
- delta: VPoint); OVERRIDE;
- { Adjust the scroll limits based on the size change of the subviews. }
-
- PROCEDURE TScroller.SetScrollLimits(scrollLimit: VPoint;
- drawScrollBars: BOOLEAN);
- { Sets the scroll of the attached scrollbars, if there are any. }
-
- PROCEDURE TScroller.SetScrollParameters(horzUnits, vertUnits: VCoordinate;
- horzConstraint, vertConstraint: BOOLEAN);
- { Sets up the fScrollUnit and fConstrain fields of the scroller. }
-
- { Scrolling Methods }
-
- PROCEDURE TScroller.HaveScrollBar(theScrollBar: TSScrollBar;
- direction: VHSelect);
- { Sets the fScrollbar field in the given 'direction' to 'theScrollBar'. }
-
- PROCEDURE TScroller.ScrollDraw(delta: VPoint;
- invalidate: BOOLEAN);
- { Method responsible for actually doing the scrolling by calling moving bits. Called
- by DoScroll. Invalidates newly revealed area if invalidate is true else updates
- the redraws the newly revealed area if invalidate is false.
- !!! NOTE this does not match the behaviour of other invalidate parameters because they
- interpret invalidate equals FALSE to neither draw nor invalidate. Well we already
- know that the way that invalidate/redraw/don't-render control is handled needs _MAJOR_
- overhauling anyways… Sigh! }
-
- PROCEDURE TScroller.DoScroll(delta: VPoint;
- redraw: BOOLEAN);
- { Method responsible for handling the scrolling, calls ScrollDraw if required. }
-
- FUNCTION TScroller.ScrollStep(vhs: VHSelect;
- partCode: INTEGER): VCoordinate;
- { Depending on the 'partCode' returns the amount to be scrolled. }
-
- FUNCTION TScroller.ScrollRelative(vhs: VHSelect;
- sBarValue: VCoordinate): VCoordinate;
- { Returns the relative amount to scroll. }
-
- PROCEDURE TScroller.ScrollBy(deltaH, deltaV: VCoordinate;
- redraw: BOOLEAN);
- { Called to scroll by 'deltaH & 'deltaV'. }
-
- PROCEDURE TScroller.ScrollTo(h, v: VCoordinate;
- redraw: BOOLEAN);
- { Scroll to the required coordinates, calls ScrollBy. }
-
- PROCEDURE TScroller.AutoScroll(viewPt: VPoint;
- VAR delta: VPoint);
- { Called during auto scrolling to return the delta to be scrolled. }
-
- PROCEDURE TScroller.RevealRect(rectToReveal: VRect;
- minToSee: Point;
- redraw: BOOLEAN); OVERRIDE;
- { Shows 'rectToReveal' with the minimum amount to be seen set to 'minToSee' by
- calling ScrollBy. }
-
- { Miscellaneous Methods }
-
- FUNCTION TScroller.DoKeyCommand(ch: Char;
- aKeyCode: INTEGER;
- VAR info: EventInfo): TCommand; OVERRIDE;
- { Handles when the Home, End, PageUp & PageDown keys are used. }
-
- FUNCTION TScroller.GetScroller(immediateSuperView: BOOLEAN): TScroller; OVERRIDE;
- { Returns SELF. }
-
- { Inspecting Methods }
-
- PROCEDURE TScroller.Fields(PROCEDURE
- DoToField(fieldName: Str255;
- fieldAddr: Ptr;
- fieldType: INTEGER)); OVERRIDE;
- { Used by the Inspector and the Debugger to display the contents of this class's
- fields. }
-
- END;
-
- {--------------------------------------------------------------------------------------------------}
- WindowTemplate = PACKED RECORD
- procID: INTEGER;
- hasGoAway: BOOLEAN;
- resizable: BOOLEAN;
- isModal: BOOLEAN;
- doFirstClick: BOOLEAN;
- freeOnClosing: BOOLEAN;
- disposeOnFree: BOOLEAN;
- closesDocument: BOOLEAN;
- openInitially: BOOLEAN;
- mustAdaptToScreen: BOOLEAN;
- stagger: BOOLEAN;
- mustForceOnScreen: BOOLEAN;
- vertCenter: BOOLEAN;
- horzCenter: BOOLEAN;
- filler: 0..7;
- targetID: IDType;
- title: Str255; {Actually variable length}
- END;
- WindowTemplatePtr = ^WindowTemplate;
-
- TWindow = OBJECT (TView) { Corresponds to a desktop Window. The
- outermost of a nested set of views. }
- fWMgrWindow: WindowPtr; { the window manager window Ptr }
- fProcID: INTEGER; { the proc ID of the window }
- fMoveBounds: Rect; { bounds over which the window may be moved
- }
- fResizeLimits: Rect; { limits over which the window may be
- resized }
- fTarget: TEvtHandler; { when this window is activated; the
- TEvtHandler to SetTarget on }
- fTargetID: IDType; { corresponding ID to fTarget }
- fPreDocname: INTEGER; { amount of window title that precedes the
- document name }
- fConstTitle: INTEGER; { amount of the title name that is constant
- }
- fIsActive: BOOLEAN; { is this window active }
- fIsResizable: BOOLEAN; { is this window resizeable }
- fIsClosable: BOOLEAN; { is this window closable }
- fFreeOnClosing: BOOLEAN; { should this window free itself when it
- closes }
- fDisposeOnFree: BOOLEAN; { should the window manager window be
- disposed when this window frees }
- fClosesDocument: BOOLEAN; { does this window close the document }
- fOpenInitially: BOOLEAN; { should this window be opened when its
- document is asked to show its windows }
- fIsModal: BOOLEAN; { should this window behave modally }
- fDoFirstClick: BOOLEAN; { should a click in this window not only
- select it if it is inactive but also be
- sent to its contents }
- fMustAdapt: BOOLEAN; { does this window require adaption to the
- screen }
- fMustHorzCenter: BOOLEAN; { does this window require centering
- horizontally }
- fMustVertCenter: BOOLEAN; { does this window require centering
- vertically }
- fMustStagger: BOOLEAN; { does this window require staggering }
- fMustForceOnScreen: BOOLEAN; { does this window require forcing on the
- screen }
- fAdapted: BOOLEAN; { has this window's size ever been adapted
- to the screen }
- fHorzCentered: BOOLEAN; { has this window been centered horizontally
- }
- fVertCentered: BOOLEAN; { has this window been centered vertically }
- fStaggered: BOOLEAN; { has this window been staggered }
- fForcedOnScreen: BOOLEAN; { has this window been forced on the screen
- }
- fFloats: BOOLEAN; { does this window float above non-floating
- windows (NOT SUPPORTED IN 2.0) }
- fContRgnInset: Point; { topleft inset of cont rgn in struc rgn }
- fContDifference: Point; { total amount the content is less than and
- offset into the structure (Accounts for
- title bar, etc.) }
-
- { Creation/Destruction Methods }
-
- PROCEDURE TWindow.IWindow(itsDocument: TDocument;
- itsWMgrWindow: WindowPtr;
- canResize, canClose, disposeOnFree: BOOLEAN);
- { Initialize a window procedurally. }
-
- PROCEDURE TWindow.IRes(itsDocument: TDocument;
- itsSuperView: TView;
- VAR itsParams: Ptr); OVERRIDE;
- { Initialize a window from a resource template. }
-
- PROCEDURE TWindow.WRes(theResource: ViewRsrcHndl;
- VAR itsParams: Ptr); OVERRIDE;
- { For writing a window out to a resource. }
-
- PROCEDURE TWindow.WriteRes(theResource: ViewRsrcHndl;
- VAR itsParams: Ptr); OVERRIDE;
- { For writing a TWindow to a resource, works in conjunction with tbe previous
- method. }
-
- PROCEDURE TWindow.Free; OVERRIDE;
- { Frees the window if fDisposeOnFree is TRUE, also deletes the window from the
- document if there is one, otherwise deletes it from the applications list of free
- windows. }
-
- { Open/Close Methods }
-
- PROCEDURE TWindow.Open; OVERRIDE;
- { Makes the window visible by showing it before calling inherited Open. }
-
- PROCEDURE TWindow.Close; OVERRIDE;
- { Calls inherited Close and the hides & deactivates the window. }
-
- PROCEDURE TWindow.CloseByUser;
- { If the window is shown and it can be closed handles the closing. }
-
- PROCEDURE TWindow.GoAwayByUser(globalMouse: Point);
- { Responsible for calling CloseByUser. }
-
- { Activation Methods }
-
- PROCEDURE TWindow.Activate(entering: BOOLEAN); OVERRIDE;
- { Activate the window. }
-
- { Size/Location Methods }
-
- PROCEDURE TWindow.Locate(h, v: VCoordinate;
- invalidate: BOOLEAN); OVERRIDE;
- { If fWMgrWindow is not NIL then MoveWindow to relocate the window. }
-
- PROCEDURE TWindow.MoveByUser(globalMouse: Point);
- { Handles the user moving the window by dragging the title bar, calls DragWindow to
- handle movement. }
-
- PROCEDURE TWindow.ResizeByUser(globalMouse: Point);
- { Handles the user resizing the window by dragging the growbox, calls GrowWindow to
- handle movement and Resize to resize the window. }
-
- PROCEDURE TWindow.Resize(width, height: VCoordinate;
- invalidate: BOOLEAN); OVERRIDE;
- { Used to resize the window by setting its width & height to the parameters passed
- in. }
-
- PROCEDURE TWindow.Zoom(partCode: INTEGER);
- { Responsible for actually handling the zooming of a window when the user clicks in
- the zoombox. }
-
- PROCEDURE TWindow.ZoomByUser(globalMouse: Point;
- partCode: INTEGER);
- { handles the user clicking in the zoombox to zoom the window, calls Zoom. }
-
- { Focusing Methods }
-
- FUNCTION TWindow.Focus: BOOLEAN; OVERRIDE;
- { Attempts to set the Focus to the window, returns TRUE if it succeeds, FALSE if not.
- }
-
- FUNCTION TWindow.FocusOnSuperView: BOOLEAN; OVERRIDE;
- { Attempts to set the Focus to our superview, returning TRUE if it succeeds or FALSE
- if not. }
-
- { Drawing Methods }
-
- PROCEDURE TWindow.DrawContents; OVERRIDE;
- { Does an EraseRect and calls inherited DrawContents before calling DrawResizeIcon. }
-
- PROCEDURE TWindow.DrawResizeIcon;
- { Draws the grow icon by calling the toolbox routine DrawGrowIcon. }
-
- { Mouse Handling Methods }
-
- FUNCTION TWindow.HandleMouseDown(theMouse: VPoint;
- VAR info: EventInfo;
- VAR hysteresis: Point;
- VAR theCommand: TCommand): BOOLEAN; OVERRIDE;
- { Handles mouse downs in the window. }
-
- FUNCTION TWindow.HasPendingUpdate: BOOLEAN; OVERRIDE;
- { Returns TRUE if there is a pending update event for this window, FALSE if not. }
-
- PROCEDURE TWindow.Update; OVERRIDE;
- { Handle the update region and drawcontents on SELF. }
-
- { Menu Handling Methods}
-
- FUNCTION TWindow.AllowsMenuAccess: BOOLEAN;
- { By default returns TRUE. }
-
- PROCEDURE TWindow.DoSetupMenus; OVERRIDE;
- { If the window is not modal calls inherited DoSetupMenus. }
-
- FUNCTION TWindow.DoMenuCommand(aCmdNumber: CmdNumber): TCommand; OVERRIDE;
- { Handles closing the window. }
-
- { Misc. Methods }
-
- PROCEDURE TWindow.Show(state, redraw: BOOLEAN); OVERRIDE;
- { Called to make the window visible or not based on 'state'. }
-
- FUNCTION TWindow.IsShown: BOOLEAN; OVERRIDE;
- { Returns TRUE if the window is currently shown. }
-
- PROCEDURE TWindow.Select;
- { Called to select the window. }
-
- PROCEDURE TWindow.SetTitle(newTitle: Str255);
- { Sets the windows title to 'newTitle'. }
-
- PROCEDURE TWindow.GetTitle(VAR theTitle: Str255);
- { Gets the current title of the window. }
-
- PROCEDURE TWindow.SetTitleForDoc(newDocTitle: Str255);
- { Called when the documents name is known or changed }
-
- PROCEDURE TWindow.AdaptToScreen;
- { Resizes the window to fit the screen on which it is being displayed. }
-
- PROCEDURE TWindow.ForceOnScreen;
- { ForceOnScreen gaurantees that some minimal drag area is accessible to the user,
- to be dragged to the desired location. }
-
- PROCEDURE TWindow.Center(horizontally, vertically, forDialog: BOOLEAN);
- { Centers the window on the screen either horizontally, vertically or both. }
-
- PROCEDURE TWindow.SimpleStagger(dh, dv: INTEGER;
- VAR counter: INTEGER);
- { Handles the staggering of windows as they are opened. }
-
- FUNCTION TWindow.GetGrafPort: GrafPtr; OVERRIDE;
- { Returns the windows GrafPtr. }
-
- PROCEDURE TWindow.GetGlobalBounds(VAR globalBounds: Rect);
- { Returns a rectangle that is the global bounds of the window. }
-
- FUNCTION TWindow.GetMaxIntersectedDevice(VAR screenRect: Rect): GDHandle;
- { Returns the screenRect of the most intersected device & its GDHandle, or
- if CQD isn't available it returns GetGrayRgn intersected with screenbits.bounds
- and NIL for the GDHandle. }
-
- FUNCTION TWindow.GetWindow: TWindow; OVERRIDE;
- { Returns SELF. }
-
- PROCEDURE TWindow.SetResizeLimits(itsMinSize, itsMaxSize: Point);
- { Used to set the limits to which the window can be resized. }
-
- PROCEDURE TWindow.SetTarget(newTarget: TEvtHandler);
- { Set fTarget to 'newTarget' and if we are the active window then call
- gApplication.SetTarget. }
-
- PROCEDURE TWindow.InstallDocument(itsDocument: TDocument);
- { Sets our fDocument field to 'itsDocument' and then installs the SELF in the
- document, if the document is not NIL. }
-
- FUNCTION TWindow.IsDraggable(whichRect: Rect): BOOLEAN;
- { Returns TRUE if any of the corner points of whichRect are draggable. }
-
- FUNCTION TWindow.BuildWindowRgns(build: BOOLEAN): BOOLEAN;
- { IF build=kBuild THEN ensures that the window regions are valid; sets
- fContRgnInset, fContDifference.
- Cleans up if necessary, when done with window regions.
- Returns the old state of the window regions. }
-
- { Inspecting Methods }
-
- PROCEDURE TWindow.Fields(PROCEDURE DoToField(fieldName: Str255;
- fieldAddr: Ptr;
- fieldType: INTEGER)); OVERRIDE;
- { Used by the Inspector and the Debugger to display the contents of this class's
- fields. }
-
- PROCEDURE TWindow.GetInspectorName(VAR inspectorName: Str255); OVERRIDE;
- { Used by the Inspector to get the name of this class. }
-
- END;
-
- {--------------------------------------------------------------------------------------------------}
- ControlTemplate = PACKED RECORD
- itsAdornment: CntlAdornment;
- filler1: Byte;
- itsPenSize: Point;
- isSizable: BOOLEAN;
- isDimmed: BOOLEAN;
- isHilited: BOOLEAN;
- canDismiss: BOOLEAN;
- filler2: 0..4095;
- itsInset: Rect;
- itsTextFace: Style;
- itsTextSize: INTEGER;
- itsTextColor: RGBColor;
- itsFontName: Str255; {Actually a variable length P-String}
- END;
- ControlTemplatePtr = ^ControlTemplate;
-
- TControl = OBJECT (TView) { An abstract class that represents a
- control. }
- fDefChoice: INTEGER; { the choice to automatically pass up the
- line via DoChoice }
- fHilite: BOOLEAN; { is this view hilited }
- fDimmed: BOOLEAN; { is this view dimmed }
- fSizeable: BOOLEAN; { is the control portion of this view
- sizeable }
- fDismissesDialog: BOOLEAN; { can this view dismiss it's dialogview }
- fAdornment: CntlAdornment; { the adornment to be drawn in addition to
- the view }
- fPenSize: Point; { pen size to be used in adorning }
- fInset: Rect; { amount to inset the control portion of the
- view }
- fTextStyle: TextStyle; { the TextStyle to use when rendering this
- view }
-
- PROCEDURE TControl.IControl(itsSuperView: TView;
- itsLocation, itsSize: VPoint;
- itsHSizeDet, itsVSizeDet: SizeDeterminer);
- { Initialize a control procedurally. }
-
- PROCEDURE TControl.IRes(itsDocument: TDocument;
- itsSuperView: TView;
- VAR itsParams: Ptr); OVERRIDE;
- { Initialize a control from a resource template. }
-
- PROCEDURE TControl.WRes(theResource: ViewRsrcHndl;
- VAR itsParams: Ptr); OVERRIDE;
- { For writing a control view out to a resource. }
-
- PROCEDURE TControl.WriteRes(theResource: ViewRsrcHndl;
- VAR itsParams: Ptr); OVERRIDE;
- { For writing a control view to a resource, works in conjunction with tbe previous
- method. }
-
- PROCEDURE TControl.ComputeSize(VAR newSize: VPoint); OVERRIDE;
- { Called to compute the control's size. }
-
- FUNCTION TControl.ContainsMouse(theMouse: VPoint): BOOLEAN; OVERRIDE;
- { Returns TRUE if 'theMouse is currently in the controls area. }
-
- PROCEDURE TControl.ControlArea(VAR theArea: Rect);
- { Returns in 'theArea' the controls active area. }
-
- PROCEDURE TControl.Dim;
- { Dims the control by drawing over it with a gray pattern. }
-
- PROCEDURE TControl.DimState(state, redraw: BOOLEAN);
- { If we are not currently dimmed then set fDimmed to 'state.and if 'redraw' is TRUE
- then call DrawContents. }
-
- FUNCTION TControl.DoMouseCommand(VAR theMouse: Point;
- VAR info: EventInfo;
- VAR hysteresis: Point): TCommand; OVERRIDE;
- { Creates a control tracker command, which is returned. }
-
- PROCEDURE TControl.Draw(area: Rect); OVERRIDE;
- { Calls Adorn to handle any adornments and the Dim & Hilite if required. }
-
- FUNCTION TControl.Focus: BOOLEAN; OVERRIDE;
- { Calls inherited Focus and if its TRUE then sets the port's text style and returns
- TRUE, if it can't be focused returns FALSE. }
-
- PROCEDURE TControl.Flash;
- { Causes a control to flash with an 8 tick delay. }
-
- PROCEDURE TControl.Hilite;
- { Hilites the control by inverting its controlarea. }
-
- PROCEDURE TControl.HiliteState(state, redraw: BOOLEAN);
- { If our fHilite is not 'state' the set it to 'state' before calling Hilite. Note:
- hilite is only called if 'redraw is TRUE and we can Focus. }
-
- PROCEDURE TControl.Inset(dh, dv: INTEGER;
- redraw: BOOLEAN);
- { If we are sizable then offset fInset to 'dh' & 'dv' redrawing if 'redraw' is TRUE.
- }
-
- FUNCTION TControl.IsDimmed: BOOLEAN;
- { Returns TRUE if the control is currently dimmed. }
-
- PROCEDURE TControl.SetInset(newInset: Rect;
- redraw: BOOLEAN);
- { Set fInset to 'newInset' redrawing if 'redraw' is TRUE. }
-
- PROCEDURE TControl.InstallColor(theColor: RGBColor;
- redraw: BOOLEAN);
- { Sets the color field of our text style record to 'theColor', if 'redraw' then call
- DrawContents. }
-
- PROCEDURE TControl.InstallTextStyle(theTextStyle: TextStyle;
- redraw: BOOLEAN);
- { Sets fTextStyle to 'theTextStyle', if 'redraw' then call DrawContents. }
-
- PROCEDURE TControl.Resize(width, height: VCoordinate;
- invalidate: BOOLEAN); OVERRIDE;
- { Calls inherited Resize before calling ForceRedraw. }
-
- PROCEDURE TControl.TrackFeedback(anchorPoint, nextPoint: VPoint;
- turnItOn, mouseDidMove: BOOLEAN); OVERRIDE;
- { Doesn't use the default feedback }
-
- PROCEDURE TControl.TrackMouse(aTrackPhase: TrackPhase;
- VAR anchorPoint, previousPoint, nextPoint: VPoint;
- mouseDidMove: BOOLEAN); OVERRIDE;
- { Called back from tracking command. Handles tracking of the mouse and then calls
- DoChoice on TrackRelease. }
-
- FUNCTION TControl.Validate: LONGINT;
- { By default returns 'noErr'. }
-
- PROCEDURE TControl.Fields(PROCEDURE
- DoToField(fieldName: Str255;
- fieldAddr: Ptr;
- fieldType: INTEGER)); OVERRIDE;
- { Used by the Inspector and the Debugger to display the contents of this class's
- fields. }
-
- END;
-
- {--------------------------------------------------------------------------------------------------}
- TCtlMgr = OBJECT (TControl) { An abstract class that represents a
- toolbox Control Manager control. }
- fCMgrControl: ControlHandle; { the Control Manager Control that is being
- managed }
- fBitsToShift: INTEGER; { # bits shifted to convert between short
- and long value. }
- fLongVal: VCoordinate; { the current value }
- fLongMin: VCoordinate; { the minimum setting }
- fLongMax: VCoordinate; { the maximum setting }
-
- PROCEDURE TCtlMgr.ICtlMgr(itsSuperView: TView;
- itsLocation, itsSize: VPoint;
- itsHSizeDet, itsVSizeDet: SizeDeterminer;
- itsTitle: Str255;
- itsVal, itsMin, itsMax: LONGINT;
- itsProcID: INTEGER);
- { Initialize procedurally. }
-
- PROCEDURE TCtlMgr.IRes(itsDocument: TDocument;
- itsSuperView: TView;
- VAR itsParams: Ptr); OVERRIDE;
- { Initialize from a resource template. }
-
- PROCEDURE TCtlMgr.WriteRes(theResource: ViewRsrcHndl;
- VAR itsParams: Ptr); OVERRIDE;
- { For writing a CtlMgr view to a resource. }
-
- PROCEDURE TCtlMgr.Free; OVERRIDE;
- { Set the size of control to zero call DisposeControl, then call inherited Free. }
-
- PROCEDURE TCtlMgr.BeInPort(itsPort: GrafPtr); OVERRIDE;
- { Sets the control to be in 'itsPort', by setting the contrlOwner field of the
- ControlHandle. }
-
- PROCEDURE TCtlMgr.CreateCMgrControl(itsBounds: Rect;
- itsTitle: Str255;
- itsVal, itsMin, itsMax: LONGINT;
- itsProcID: INTEGER);
- { Used to create a new control, calls NewControl to create the control. }
-
- PROCEDURE TCtlMgr.DimState(state, redraw: BOOLEAN); OVERRIDE;
- { Set the dim state to 'state' and redrawing it if 'redraw'. }
-
- FUNCTION TCtlMgr.DoMouseCommand(VAR theMouse: Point;
- VAR info: EventInfo;
- VAR hysteresis: Point): TCommand; OVERRIDE;
- { Handles mouse downs in the control by calling TestControl and DoChoice, returns
- NIL. }
-
- PROCEDURE TCtlMgr.Draw(area: Rect); OVERRIDE;
- { Draws the control by calling the toolbox routine ShowControl. }
-
- { Methods to manipulate the TCtlMgr values }
- FUNCTION TCtlMgr.GetLongMax: VCoordinate;
- { Returns the current fLongMax value. }
-
- FUNCTION TCtlMgr.GetLongMin: VCoordinate;
- { Returns the current fLongMin value. }
-
- FUNCTION TCtlMgr.GetLongVal: VCoordinate;
- { Returns the current fLongVal value. }
-
- PROCEDURE TCtlMgr.SetLongMax(itsMax: VCoordinate;
- redraw: BOOLEAN);
- { Sets fLongMax to 'itsMax', redrawing if required. }
-
- PROCEDURE TCtlMgr.SetLongMin(itsMin: VCoordinate;
- redraw: BOOLEAN);
- { Sets flongMin to 'itsMin', redrawing if required. }
-
- PROCEDURE TCtlMgr.SetLongVal(itsVal: VCoordinate;
- redraw: BOOLEAN);
- { Sets fLongVal to 'itsVal' redrawing if required. }
-
- PROCEDURE TCtlMgr.SetLongValues(itsVal, itsMin, itsMax: VCoordinate;
- redraw: BOOLEAN);
- { Sets all of the values at once, redrawing if required. }
-
- { Methods to manipulate the Control Manager control values }
- FUNCTION TCtlMgr.GetMax: INTEGER;
- { Returns the maximum value of the Control Manager control. }
-
- FUNCTION TCtlMgr.GetMin: INTEGER;
- { Returns the minimum value of the Control Manager control. }
-
- PROCEDURE TCtlMgr.GetText(VAR theText: Str255);
- { Returns the controls title, if any. }
-
- FUNCTION TCtlMgr.GetVal: INTEGER;
- { Returns the current value of the Control Manager control. }
-
- PROCEDURE TCtlMgr.SetMax(itsMax: INTEGER;
- redraw: BOOLEAN);
- { While focused sets the maximum value of the Control Manager control to 'itsMax'. }
-
- PROCEDURE TCtlMgr.SetMin(itsMin: INTEGER;
- redraw: BOOLEAN);
- { While focused sets the minimum value of the Control Manager control to 'itsMin'. }
-
- PROCEDURE TCtlMgr.SetText(itsText: Str255;
- redraw: BOOLEAN);
- { Sets the controls title to 'itsText', redrawing if required. }
-
- PROCEDURE TCtlMgr.SetVal(newVal: INTEGER;
- redraw: BOOLEAN);
- { While focused sets the Control Manager controls value to 'newVal', redrawing if required. }
-
- PROCEDURE TCtlMgr.SetValues(itsVal, itsMin, itsMax: INTEGER;
- redraw: BOOLEAN);
- { While focused sets all the values of the Control Manager control, at once, redrawing if required. }
-
- PROCEDURE TCtlMgr.HiliteState(state, redraw: BOOLEAN); OVERRIDE;
- { Set the hilite state to 'state', redrawing if required.If hilite state is currently
- 'state' then does nothing. }
-
- FUNCTION TCtlMgr.IsCMgrVisible: BOOLEAN;
- { Returns TRUE if the control is currently visible, FALSE if not. }
-
- PROCEDURE TCtlMgr.Resize(width, height: VCoordinate;
- invalidate: BOOLEAN); OVERRIDE;
- { If the control is resizable calls the toolbox routines MoveControl & SizeControl
- before calling inherited Resize. }
-
- PROCEDURE TCtlMgr.SetCMgrVisibility(beVisible: BOOLEAN);
- { Sets the visibility of the control to 'isVisible'. }
-
- PROCEDURE TCtlMgr.WhileFocused(PROCEDURE DoToControl;
- redraw: BOOLEAN);
- { While focused call "DoToControl", redrawing if required. }
-
- PROCEDURE TCtlMgr.Fields(PROCEDURE DoToField(fieldName: Str255;
- fieldAddr: Ptr;
- fieldType: INTEGER)); OVERRIDE;
- { Used by the Inspector and the Debugger to display the contents of this class's
- fields. }
- END;
-
- {--------------------------------------------------------------------------------------------------}
- ScrollBarTemplate = RECORD
- value: LONGINT;
- minimum: LONGINT;
- maximum: LONGINT;
- END;
- ScrollBarTemplatePtr = ^ScrollBarTemplate;
-
- TScrollBar = OBJECT (TCtlMgr) { A subclass of TCtlMgr that maps between
- longint values for our view coordinates
- and the integers of a toolbox scrollbar. }
- fDirection: VHSelect; { is this a horizontal or vertical scrollbar
- }
-
- PROCEDURE TScrollBar.IScrollBar(itsSuperView: TView;
- itsLocation, itsSize: VPoint;
- itsHSizeDet, itsVSizeDet: SizeDeterminer;
- itsDirection: VHSelect;
- itsVal, itsMin, itsMax: LONGINT);
- { Initialize a scrollbar procedurally. }
-
- PROCEDURE TScrollBar.IRes(itsDocument: TDocument;
- itsSuperView: TView;
- VAR itsParams: Ptr); OVERRIDE;
- { Initialize a scrollbar from a resource template. }
-
- PROCEDURE TScrollBar.WRes(theResource: ViewRsrcHndl;
- VAR itsParams: Ptr); OVERRIDE;
- { For writing a dialog view out to a resource. }
-
- PROCEDURE TScrollBar.WriteRes(theResource: ViewRsrcHndl;
- VAR itsParams: Ptr); OVERRIDE;
- { For writing a scrollbar to a resource, works in conjunction with tbe previous
- method. }
-
- PROCEDURE TScrollBar.DeltaValue(delta: VCoordinate);
- { Does range checking on 'delta' checking it against fLongMin & fLongMax for the
- scrollbar. }
-
- FUNCTION TScrollBar.DoMouseCommand(VAR theMouse: Point;
- VAR info: EventInfo;
- VAR hysteresis: Point): TCommand; OVERRIDE;
- { Handles the mouse down in the various parts of the scrollbar. }
-
- PROCEDURE TScrollBar.TrackScrollBar(partCode: INTEGER);
- { Tracks the scrollbar by calling DeltaValue. }
-
- PROCEDURE TScrollBar.ActionProc(partCode: INTEGER);
- { Forwarded to from the global routine: ActionProcForTScrollBar which was set as the
- ScrollBar's action proc. Typically forwards again to TrackScrollBar after bounds
- checking and Updates before returning to the ScrollBar. }
-
- { Inspecting }
-
- PROCEDURE TScrollBar.Fields(PROCEDURE
- DoToField(fieldName: Str255;
- fieldAddr: Ptr;
- fieldType: INTEGER)); OVERRIDE;
- { Used by the Inspector and the Debugger to display the contents to this class's
- fields. }
- END;
-
- {--------------------------------------------------------------------------------------------------}
- TSScrollBar = OBJECT (TScrollBar) { A subclass of TScrollBar that is
- associated with one or more scrollers. }
- fScrollers: TList; { the associated scrollers if any }
-
- PROCEDURE TSScrollBar.ISScrollBar(itsSuperView: TView;
- itsLocation, itsSize: VPoint;
- itsHSizeDet, itsVSizeDet: SizeDeterminer;
- itsDirection: VHSelect;
- itsMax: LONGINT;
- itsScroller: TScroller);
- { Initialize the scrollbar procedurally. }
-
- PROCEDURE TSScrollBar.IRes(itsDocument: TDocument;
- itsSuperView: TView;
- VAR itsParams: Ptr); OVERRIDE;
- { Initialize the scrollbar from a resource template. }
-
- PROCEDURE TSScrollBar.WriteRes(theResource: ViewRsrcHndl;
- VAR itsParams: Ptr); OVERRIDE;
- { For writing an sscrollbar out to a resource. }
-
- PROCEDURE TSScrollBar.Free; OVERRIDE;
- { If the scrollers are not NIL then first detach the scrollbars from them before
- freeing the scrollers, then call inherited Free. }
-
- PROCEDURE TSScrollBar.AttachScroller(itsScroller: TScroller);
- { IF 'itsScroller' is not NIL then add it to our list and attach ourselves to it. }
-
- PROCEDURE TSScrollBar.BeInPort(itsPort: GrafPtr); OVERRIDE;
- { Call inherited BeInPort and then set our visibility based on the state of the
- window we are in. }
-
- PROCEDURE TSScrollBar.Activate(entering: BOOLEAN); OVERRIDE;
- { If 'entering' is TRUE then show ourselves, otherwise just call Draw to frame our
- area. }
-
- FUNCTION TSScrollBar.DoMouseCommand(VAR theMouse: Point;
- VAR info: EventInfo;
- VAR hysteresis: Point): TCommand; OVERRIDE;
- { Handles mouse downs in the scrollbar. }
-
- PROCEDURE TSScrollBar.Draw(area: Rect); OVERRIDE;
- { Draws a frame around the controls area before calling inherited Draw. }
-
- PROCEDURE TSScrollBar.TrackScrollBar(partCode: INTEGER); OVERRIDE;
- { Called to handle tracking of the scrollbar by calling DeltaValue. }
-
- { Inspecting }
-
- PROCEDURE TSScrollBar.Fields(PROCEDURE
- DoToField(fieldName: Str255;
- fieldAddr: Ptr;
- fieldType: INTEGER)); OVERRIDE;
- { Used by the Inspector and the Debugger to display the contents of this class's
- fields. }
- END;
-
- {--------------------------------------------------------------------------------------------------}
- TDeskScrapView = OBJECT (TView) { The default view in the Clipboard, able to
- display only standard text and pictures. }
- fHavePicture: BOOLEAN; { are we holding a PICT }
- fHaveText: BOOLEAN; { is there any TEXT }
- fScrapCount: INTEGER; { scrapCount of the scrap represented by
- this view.}
-
- fDataHandle: Handle; { if non-NIL, will be either a PicHandle to
- my picture or a Handle to my Text }
-
- PROCEDURE TDeskScrapView.IDeskScrapView;
- { Initialize the deskscrap view procedurally. }
-
- PROCEDURE TDeskScrapView.IRes(itsDocument: TDocument;
- itsSuperView: TView;
- VAR itsParams: Ptr); OVERRIDE;
- { Initialize the deskscrap view from a resource template. }
-
- PROCEDURE TDeskScrapView.Free; OVERRIDE;
- { Does nothing, don't ever want to free gClipOrphange. }
-
- PROCEDURE TDeskScrapView.CheckScrapContents;
- { Checks the contents of the deskscrap. }
-
- PROCEDURE TDeskScrapView.CalcMinSize(VAR minSize: VPoint); OVERRIDE;
- { Responsible for calculating the correct size for the deskscrap view. }
-
- PROCEDURE TDeskScrapView.Draw(area: Rect); OVERRIDE;
- { handles the drawing of the contents of the deskscrap, which by default is either a
- PICT or text. }
-
- PROCEDURE TDeskScrapView.SuperViewChangedSize(delta: VPoint;
- invalidate: BOOLEAN); OVERRIDE;
- { If our superview changes size then call AdjustSize & ForceRedraw. }
-
- PROCEDURE TDeskScrapView.WriteToDeskScrap; OVERRIDE;
- { This view represents data that is already written to the deskscrap, so this does
- nothing. }
-
- { Inspecting }
- PROCEDURE TDeskScrapView.GetInspectorName(VAR inspectorName: Str255); OVERRIDE;
- { Used by the Inspector to get the name of this class. }
-
- PROCEDURE TDeskScrapView.Fields(PROCEDURE
- DoToField(fieldName: Str255;
- fieldAddr: Ptr;
- fieldType: INTEGER)); OVERRIDE;
- { Used by the Inspector and the Debugger to display the contents of this class's
- fields. }
-
- END;
-
- {--------------------------------------------------------------------------------------------------}
- TPrintHandler = OBJECT (TEvtHandler) { Handles printing at a specified resolution
- on behalf of a view. This class is really
- a non-functional stub for programs that
- don't use the printing building block. }
- fView: TView; { The view whose printing is handled }
- fDocument: TDocument; { the document printed by this handler }
- fDeviceRes: Point; { formal printer resolution, spots per inch
- }
- fViewPerPage: VPoint; { The amount of the view that is visible on
- a page }
- fFocusedPage: INTEGER; { The page number currently focused }
-
- { Initialization and termination }
-
- PROCEDURE TPrintHandler.IPrintHandler(itsView: TView);
- { Initialize the printHandler, and associate it and 'itsView' with each other }
-
- PROCEDURE TPrintHandler.GetInspectorName(VAR inspectorName: Str255); OVERRIDE;
- { Used by the inspector to get the name of this class. }
-
- PROCEDURE TPrintHandler.Fields(PROCEDURE
- DoToField(fieldName: Str255;
- fieldAddr: Ptr;
- fieldType: INTEGER)); OVERRIDE;
- { Used by the Inspector and the Debugger to display the contents of this class's
- fields. }
-
- PROCEDURE TPrintHandler.FocusOnInterior;
- { Stub }
-
- PROCEDURE TPrintHandler.SetDefaultPrintInfo;
- { Stub }
-
- { Printing-related reformatting and computations }
-
- FUNCTION TPrintHandler.BreakFollowing(vhs: VHSelect;
- prevBreak: VCoordinate;
- VAR automatic: BOOLEAN): VCoordinate;
- { Returns the location of the page break which follows the page break located at
- 'prevBreak', in direction vhs; returns automatic = TRUE if the page-break is
- thought of as an 'automatic' rather than a 'manual' (user-specified) one. Note that
- page-breaks in dimension 'v' are drawn as vertical lines, those in dimension 'h' as
- horizontal lines }
-
- PROCEDURE TPrintHandler.CalcPageStrips(VAR pageStrips: Point);
- { Recalculate the number of strips of pages in each dimension }
-
- PROCEDURE TPrintHandler.CalcViewPerPage(VAR amtPerPage: VPoint);
- { Computes the amount of view, in each dimension, to be allocated to a printed page }
-
- PROCEDURE TPrintHandler.CheckPrinter;
- { See if there are changed printer-configuration parameters which need to be
- absorbed, and if so, absorb them }
-
- PROCEDURE TPrintHandler.LocatePageInterior(pageNumber: INTEGER;
- VAR loc: Point);
- { Decide where the top-left-most point of the the interior of the page should be }
-
- PROCEDURE TPrintHandler.PrinterChanged;
- { The metrics relating to printer use have changed; absorb the information and react
- }
-
- PROCEDURE TPrintHandler.RedoPageBreaks;
- { Recompute the dividing lines between areas of the view which will be mapped into
- different printed pages }
-
- PROCEDURE TPrintHandler.Reset;
- { Resets the print handler to the default values }
-
- { Printing-related commands }
-
- FUNCTION TPrintHandler.Print(itsCmdNumber: CmdNumber;
- VAR proceed: BOOLEAN): TCommand; {+}
- { By default sets 'proceed' to TRUE and returns NIL. }
-
- FUNCTION TPrintHandler.SetupForFinder: BOOLEAN;
- { Intended to set up the print handler for finder printing. }
-
- { Printing-related screen feedback }
-
- PROCEDURE TPrintHandler.DrawPrintFeedback(area: Rect);
- { Draw page-breaks, page-numbers, view-borders, rulers, etc. }
-
- PROCEDURE TPrintHandler.DrawPageBreak(vhs: VHSelect;
- whichBreak: INTEGER;
- loc: VCoordinate;
- automatic: BOOLEAN);
- { Does nothing. }
-
- { Actual printing }
-
- FUNCTION TPrintHandler.MaxPageNumber: INTEGER;
- { Returns the largest page number which could be reasonably printed, given the
- properties of the view; in cases like a SpreadSheet, this is not necessarily as
- large as the product (row strips) x (column strips) }
-
- PROCEDURE TPrintHandler.SetPageInterior(pageNumber: INTEGER);
- { Set up the pad-space Interior rectangle for the given page number }
-
- PROCEDURE TPrintHandler.SetPageOffset(coord: VPoint);
- { Given the view coordinates of the top-left-most point of the view which is being
- mapped into the current page (in coord), this method's job is to compute the
- correct fRelOrigin field for the current page }
-
- END;
-
- {--------------------------------------------------------------------------------------------------}
- TCommand = OBJECT (TObject) { Handles a user command, including undoing
- and mouse-tracking if required. Usually
- created by the part of the Application
- with the greatest specific knowledge about
- the action to take in response to events
- and passed back to be performed at several
- well defined places.}
- fCmdNumber: CmdNumber; { Can be a many-to-one mapping of fCmdNumber
- to TCommand }
- fView: TView; { The view affected by this command, and in
- which tracking takes place, if any. }
- fChangedDocument: TDocument; { the document changed by this command }
- fCmdDone: BOOLEAN; { TRUE if the last "execution" message sent
- to the command was DoIt or RedoIt }
- fCanUndo: BOOLEAN; { Defaults to TRUE }
- fCausesChange: BOOLEAN; { Defaults to TRUE; Marks document changed
- when command is done }
- fChangesClipboard: BOOLEAN; { Defaults to FALSE. Set to true for command
- subclasses representing CUT and/ or COPY
- commands which change the Clipboard. }
- fFreeOnCompletion: BOOLEAN; { TRUE to cause the command to be freed on
- completion (the default). Completion is
- after DoIt for non-undoable commands and
- Commit for undoable commands. }
- fPriority: CommandPriority; { How this command should be prioritized if
- it has do compete on a prioritized basis
- for execution. kNormalPriority is the
- Default. Most programs won't have to mess
- with this. }
- fReadyToExecute: BOOLEAN; { TRUE (the default) will enable this
- command to be returned from any queues
- that may be holding it. Most programs
- won't have to mess with this. }
- fRecurring: BOOLEAN; { FALSE (the default) will enable this
- command to be removed from any command
- queue that holds it because it is only
- executed once. }
- { The remaining fields are for command objects that track the mouse.
- A future version of MacApp will have probably have Trackers as a subclass of TCommand.
- Left now for compatibility (2.0) }
- fTracksMouse: BOOLEAN; { TRUE if the command should be tracked. }
- fInitialPt: Point; { Where to track from (usually where the
- mouse went down) in global coordinates.
- MacApp sets this field in
- TApplication.HandleMooseDown, you set it
- if you create trackers that don't get
- passed back up through that call chain. }
-
- fConstrainsMouse: BOOLEAN; { Defaults to FALSE; if you set to TRUE then
- TrackConstrain will be called to constrain
- the mouse. }
- fViewConstrain: BOOLEAN; { Defaults to TRUE, which means constrain
- mouse to view limits }
- fTrackNonMovement: BOOLEAN; { Defaults to FALSE, which means don't track
- mouse unless it moves. }
- fScroller: TScroller; { The scroller that handles auto-scrolling }
-
- { Init & Free }
- PROCEDURE TCommand.ICommand(itsCmdNumber: CmdNumber;
- itsDocument: TDocument;
- itsView: TView;
- itsScroller: TScroller);
- { Initialize a command procedurally. }
-
- { Inspecting }
- PROCEDURE TCommand.Fields(PROCEDURE
- DoToField(fieldName: Str255;
- fieldAddr: Ptr;
- fieldType: INTEGER)); OVERRIDE;
- { Used by the Inspector and the Debugger to display the contents of this class's
- fields. }
-
- { command processing - usually overridden }
-
- PROCEDURE TCommand.Commit;
- { Stub }
-
- PROCEDURE TCommand.DoIt;
- { Stub }
-
- PROCEDURE TCommand.RedoIt;
- { Stub }
-
- PROCEDURE TCommand.UndoIt;
- { Stub }
-
- { Scheduling }
- FUNCTION TCommand.IsReadyToExecute: BOOLEAN;
- { Returns TRUE (the Default) when the command is ready to execute. Override to base
- the execution of the command on more sophisticated criteria.
- Most programs won't have to mess with this.. }
-
- { Mouse Tracking }
-
- FUNCTION TCommand.IsDoneTracking: BOOLEAN;
- { Indicates whether the Command is through tracking. (the command is also through
- tracking if you return NIL from TrackMouse). Defaults to fView.IsDoneTracking.
- Most programs won't have to mess with this.
- NOTE you still have to deal with queued events if you change the criteria for TRUE. }
-
- PROCEDURE TCommand.TrackConstrain(anchorPoint, previousPoint: VPoint;
- VAR nextPoint: VPoint);
- { Override this if you want to constrain the mouse point to a grid, force drawing a
- square, etc. This is called only if fConstrainsMouse is TRUE. }
-
- PROCEDURE TCommand.TrackFeedback(anchorPoint, nextPoint: VPoint;
- turnItOn, mouseDidMove: BOOLEAN);
- { Default is: IF NOT mouseDidMove THEN FrameRect(<rect formed by anchorPoint and
- nextPoint>). Before this is called the pen is set to PenNormal and the PenMode to
- PatXOR. }
-
- FUNCTION TCommand.TrackMouse(aTrackPhase: TrackPhase;
- VAR anchorPoint, previousPoint, nextPoint: VPoint;
- mouseDidMove: BOOLEAN): TCommand;
- { This does the mouse tracking. The default returns SELF. Override it to force
- gridding, to return a different type of command, or to perform the command on mouse
- release instead of using the usual DoIt approach. All points are in local
- coordinates. If aTrackPhase = trackPress then all 3 points will be the same. If
- aTrackPhase = trackRelease then nextPoint will be the coordinate in the mouseUp
- event (if a mouseUp event is found), otherwise the same point as previousPoint.
- Generally, you will ignore nextPoint and just look at previousPoint. mouseDidMove
- will be TRUE if aTrackPhase = trackPress or trackRelease; otherwise, it will
- indicate if nextPoint = previousPoint. If you change anchorPoint, the new value
- will be passed to you next time. The value of nextPoint at the time the routine
- exits will be passed to you as previousPoint the next time the routine is called.
- You can change nextPoint if you wish. Usually, however, you will do gridding in the
- TrackConstrain method. }
-
- PROCEDURE TCommand.AutoScroll(deltaH, deltaV: VCoordinate);
- { Implements autoscrolling by calling fScroller.ScrollBy. }
-
- END;
-
- {--------------------------------------------------------------------------------------------------}
- TNoChangesCommand = OBJECT (TCommand) { Doesn't "change" the document and is not
- itself undoable. Thus it doesn't flush the
- last command that did. Useful for
- deferring actions out to the
- PerformCommand bottleneck where the stack
- is unwound and the heap is unloaded for
- maximum elbow room. }
- PROCEDURE TNoChangesCommand.INoChangesCommand(itsCmdNumber: CmdNumber;
- itsDocument: TDocument;
- itsView: TView;
- itsScroller: TScroller);
-
- PROCEDURE TNoChangesCommand.Fields(PROCEDURE
- DoToField(fieldName: Str255;
- fieldAddr: Ptr;
- fieldType: INTEGER)); OVERRIDE;
- { Used by the Inspector and the Debugger to display the contents of this class's
- fields. }
-
- END;
-
- {--------------------------------------------------------------------------------------------------}
- TControlTracker = OBJECT (TNoChangesCommand) { a command adapted for tracking
- controls. }
- fControl: TControl; { the object of our desire }
-
- PROCEDURE TControlTracker.IControlTracker(theControl: TControl);
- { Initialize the tracker procedurally. }
-
- { Inspecting }
- PROCEDURE TControlTracker.Fields(PROCEDURE
- DoToField(fieldName: Str255;
- fieldAddr: Ptr;
- fieldType: INTEGER)); OVERRIDE;
- { Used by the Inspector and the Debugger to display the contents of this class's
- fields. }
-
- END;
-
- {--------------------------------------------------------------------------------------------------}
- { commands that are created in response to common operations and will forward to the
- appropriate action }
-
- {$IFC qDebug}
- TDebugCommand = OBJECT (TNoChangesCommand) { Causes the MacApp Debugger to be
- entered }
- PROCEDURE TDebugCommand.IDebugCommand(itsCmdNumber: CmdNumber);
- { Initialize the DebugCommand procedurally. }
-
- PROCEDURE TDebugCommand.DoIt; OVERRIDE;
- { Cause the MacApp Debugger to be entered }
-
- PROCEDURE TDebugCommand.Fields(PROCEDURE
- DoToField(fieldName: Str255;
- fieldAddr: Ptr;
- fieldType: INTEGER)); OVERRIDE;
- { Used by the Inspector and the Debugger to display the contents of this class's
- fields. }
-
- END;
- {$ENDC}
-
- {--------------------------------------------------------------------------------------------------}
- {$IFC qInspector}
- TInspectorCommand = OBJECT (TNoChangesCommand) { Tells the inspector to make a new
- window }
- PROCEDURE TInspectorCommand.IInspectorCommand(itsCmdNumber: CmdNumber);
- { Initialize the DebugCommand procedurally. }
-
- PROCEDURE TInspectorCommand.DoIt; OVERRIDE;
- { Tell the inspector to make a new window }
-
- PROCEDURE TInspectorCommand.Fields(PROCEDURE
- DoToField(fieldName: Str255;
- fieldAddr: Ptr;
- fieldType: INTEGER)); OVERRIDE;
- { Used by the Inspector and the Debugger to display the contents of this class's
- fields. }
-
- END;
- {$ENDC}
-
- {--------------------------------------------------------------------------------------------------}
- TNewDocCommand = OBJECT (TNoChangesCommand) { Tells the application open a new
- document. }
- PROCEDURE TNewDocCommand.INewDocCommand(itsCmdNumber: CmdNumber);
- { Initialize the NewDocCommand procedurally. }
-
- PROCEDURE TNewDocCommand.DoIt; OVERRIDE;
- { tell the application open a new document. }
-
- PROCEDURE TNewDocCommand.Fields(PROCEDURE
- DoToField(fieldName: Str255;
- fieldAddr: Ptr;
- fieldType: INTEGER)); OVERRIDE;
- { Used by the Inspector and the Debugger to display the contents of this class's
- fields. }
-
- END;
-
- {--------------------------------------------------------------------------------------------------}
- TOldDocCommand = OBJECT (TNoChangesCommand) { Tells the application to open an old
- document. }
- PROCEDURE TOldDocCommand.IOldDocCommand(itsCmdNumber: CmdNumber);
- { Initialize the OldDocCommand procedurally. }
-
- PROCEDURE TOldDocCommand.DoIt; OVERRIDE;
- { tell the application to open an old document. }
-
- PROCEDURE TOldDocCommand.Fields(PROCEDURE
- DoToField(fieldName: Str255;
- fieldAddr: Ptr;
- fieldType: INTEGER)); OVERRIDE;
- { Used by the Inspector and the Debugger to display the contents of this class's
- fields. }
-
- END;
-
- {--------------------------------------------------------------------------------------------------}
- TCloseWindowCommand = OBJECT (TNoChangesCommand) { Tells the application close a window.
- }
- PROCEDURE TCloseWindowCommand.ICloseWindowCommand(itsCmdNumber: CmdNumber;
- itsWindow: TWindow);
- { Initialize the CloseWindowCommand procedurally. }
-
- PROCEDURE TCloseWindowCommand.DoIt; OVERRIDE;
- { tell the application to close a window. }
-
- PROCEDURE TCloseWindowCommand.Fields(PROCEDURE
- DoToField(fieldName: Str255;
- fieldAddr: Ptr;
- fieldType: INTEGER)); OVERRIDE;
- { Used by the Inspector and the Debugger to display the contents of this class's
- fields. }
-
- END;
-
- {--------------------------------------------------------------------------------------------------}
- TQuitCommand = OBJECT (TNoChangesCommand) { Tells the application to quit. }
- PROCEDURE TQuitCommand.IQuitCommand(itsCmdNumber: CmdNumber);
- { Initialize the QuitCommand procedurally. }
-
- PROCEDURE TQuitCommand.DoIt; OVERRIDE;
- { tell the application to quit. }
-
- PROCEDURE TQuitCommand.Fields(PROCEDURE
- DoToField(fieldName: Str255;
- fieldAddr: Ptr;
- fieldType: INTEGER)); OVERRIDE;
- { Used by the Inspector and the Debugger to display the contents of this class's
- fields. }
-
- END;
-
- {--------------------------------------------------------------------------------------------------}
- TUndoRedoCommand = OBJECT (TNoChangesCommand) { Tells the application to undo/redo
- the last undoable command }
- PROCEDURE TUndoRedoCommand.IUndoRedoCommand(itsCmdNumber: CmdNumber);
- { Initialize the UndoRedoCommand procedurally. }
-
- PROCEDURE TUndoRedoCommand.DoIt; OVERRIDE;
- { tell the application to undo/redo. }
- PROCEDURE TUndoRedoCommand.Fields(PROCEDURE
- DoToField(fieldName: Str255;
- fieldAddr: Ptr;
- fieldType: INTEGER)); OVERRIDE;
- { Used by the Inspector and the Debugger to display the contents of this class's
- fields. }
-
- END;
-
- {--------------------------------------------------------------------------------------------------}
- TAboutAppCommand = OBJECT (TNoChangesCommand) { Tells the application to show its
- about box. }
- PROCEDURE TAboutAppCommand.IAboutAppCommand(itsCmdNumber: CmdNumber);
- { Initialize the AboutAppCommand procedurally. }
-
- PROCEDURE TAboutAppCommand.DoIt; OVERRIDE;
- { tell the application to DoShowAboutApp. }
- PROCEDURE TAboutAppCommand.Fields(PROCEDURE
- DoToField(fieldName: Str255;
- fieldAddr: Ptr;
- fieldType: INTEGER)); OVERRIDE;
- { Used by the Inspector and the Debugger to display the contents of this class's
- fields. }
-
- END;
-
- {--------------------------------------------------------------------------------------------------}
- TSaveDocCommand = OBJECT (TNoChangesCommand) { Tells the document to save. }
- PROCEDURE TSaveDocCommand.ISaveDocCommand(itsCmdNumber: CmdNumber;
- itsDocument: TDocument);
- { Initialize the SaveDocCommand procedurally. }
-
- PROCEDURE TSaveDocCommand.DoIt; OVERRIDE;
- { tell the document to save. }
-
- PROCEDURE TSaveDocCommand.Fields(PROCEDURE
- DoToField(fieldName: Str255;
- fieldAddr: Ptr;
- fieldType: INTEGER)); OVERRIDE;
- { Used by the Inspector and the Debugger to display the contents of this class's
- fields. }
-
- END;
-
- {--------------------------------------------------------------------------------------------------}
- TRevertDocCommand = OBJECT (TNoChangesCommand) { Tells the document to revert after
- checking with the user }
- PROCEDURE TRevertDocCommand.IRevertDocCommand(itsCmdNumber: CmdNumber;
- itsDocument: TDocument);
- { Initialize the RevertDocCommand procedurally. }
-
- PROCEDURE TRevertDocCommand.DoIt; OVERRIDE;
- { tell the document to revert if the user says OK. }
-
- PROCEDURE TRevertDocCommand.Fields(PROCEDURE
- DoToField(fieldName: Str255;
- fieldAddr: Ptr;
- fieldType: INTEGER)); OVERRIDE;
- { Used by the Inspector and the Debugger to display the contents of this class's
- fields. }
-
- END;
-
- {--------------------------------------------------------------------------------------------------}
- TCommandList = OBJECT (TSortedList) { A list for keeping TCommands ordered by
- priority }
- PROCEDURE TCommandList.ICommandList;
- { Initialize the CommandList procedurally. }
-
- FUNCTION TCommandList.Compare(item1, item2: TObject): INTEGER; OVERRIDE;
- { Compares Two TCommands based on their priority }
-
- PROCEDURE TCommandList.Insert(item: TObject); OVERRIDE;
- { Overridden to guarantee insertion even in low memory and to preserve arrival
- sequence within "Compare" ordering. }
-
- PROCEDURE TCommandList.Fields(PROCEDURE
- DoToField(fieldName: Str255;
- fieldAddr: Ptr;
- fieldType: INTEGER)); OVERRIDE;
- { Used by the Inspector and the Debugger to display the contents of this class's
- fields. }
-
- END;
-
- {--------------------------------------------------------------------------------------------------}
-
- VAR
- gAlwaysTrackCursor: BOOLEAN; { set this to TRUE when you want the
- application to track the cursor even if it
- doesn't stray outside gCursorRgn. }
- gAppDone: BOOLEAN; { set this to TRUE when you want the
- application to terminate }
- gApplicationStyle: TextStyle; { Application's default text style }
- {$Push} {$J+}
- gApplication: TApplication; { the application object }
- {$Pop}
-
- {$IFC qDebug}
- gAssumeFocused: BOOLEAN; { Actually do TView.AssumeFocused checking?
- }
- gBusyTempRgn: BOOLEAN; { Is gTempRgn in use? }
- {$ENDC}
- gChooserOK: BOOLEAN; { if FALSE, user will not be allowed to
- change the printer selection using 'Choose
- Printer' DA while the application is
- alive; if TRUE (the default set in
- InitUMacApp), then printer-change will
- only be disabled during background
- printing. If you want it FALSE in your
- application, the right time to set it is
- after calling InitUMacApp (where it is
- initialized to TRUE) and before calling
- InitPrinting (where, if it's found to be
- FALSE, the low- memory location governing
- is option is poked). In the MultiFinder™
- world this is pretty questionable
- behaviour, though. }
- gClickCount: INTEGER; { number of 'saved up' mouse clicks; handled
- in TApplication.DispatchEvent, ObeyEvent &
- ObeyMouseDown. If a mouseDown, the value
- is that returned by the call to
- TApplication.CountClicks. If a mouseUp,
- the value is left alone. Otherwise, set to
- 0. Also set to 0 is the 2 clicks were in
- different parts ofthe window. }
- gClipClaimed: BOOLEAN; { Used by PerformCommand & ClaimClipboard to
- determine, if DoIt of a cut/copy cmd
- fails, whether the Clipboard had already
- been claimed by the new command or not }
- gClipOrphanage: TView; { A view to represent the Clipboard when the
- application can't }
-
- gClipUndoView: TView; { The view previously installed in the
- Clipboard }
-
- gClipView: TView; { The view currently installed in the
- Clipboard }
- gClipWindow: TWindow; { The window holding the Clipboard display }
- gClipWrittenToDeskScrap: BOOLEAN; { True if the clipboard view has been
- written to the desk scrap. }
- gCouldPrint: BOOLEAN; { whether Printer code is accessible to the
- application }
- gCurrPrintHandler: TPrintHandler; { If printing, this is set to the print
- handler. Nil if not printing. }
- {$IFC qDebug}
- gDebugPrinting: BOOLEAN; { simple toggle for debugging printing }
- {$ENDC}
- gDocList: TList; { list of documents }
- gDrawingPictScrap: BOOLEAN; { TRUE if a view's Draw routine is being
- called in order to create PICT data in the
- Desk Scrap; your View.Draw can check this
- routine, and insert PictComments as
- appropriate if it wishes to have them in
- the Picture in the Desk Scrap }
- gDrawingPictScrapView: TView; { the view being currently drawn in the PICT
- scrap ??? this stuff is a good candidate
- for a small change to the view
- architecture to more easily allow
- providing alternate drawing environments }
- {$IFC qExperimentalAndUnsupported}
- gEnableDoubleBuffering: BOOLEAN; { TRUE to enable automatic double buffering
- when drawing/scrolling views }
- {$EndC}
-
- gErrorParm3: Str255; { This is used as the last argument to
- ParamText in ErrorAlert, if ErrorAlert
- displays one of the standard alerts. (This
- string will replace ^3 in those alerts.)
- ErrorAlert also sets this to '' when
- called. You can use this to parameterize
- the automatic alerts that MacApp displays.
- For example, TDocument.ReadFromFile sets
- this to the document name. }
- gEventLevel: INTEGER; { A count of the number of nested calls to
- PollEvent. }
- {$IFC qDebug}
- gExperimenting: BOOLEAN; { simple toggle for enabling/disabling
- experimental features }
- {$ENDC}
- gFakeWindow: WindowRecord; { In MacApp 2.0 and earlier, this was
- initialized with OpenPort, or OpenCPort,
- and by setting its ControlList to NIL.
- This was NOT a real window, just a port.
- In MacApp 2.0.1 and later, this is a
- real window. It's ignored in routines that
- iterate over the windowList. }
-
- gFileCount: INTEGER; { # files to open/print from finder; set in
- Init2 }
- gFinderPrinting: BOOLEAN; { TRUE if the Finder started the App up just
- for printing docs }
- gFocusedView: TView; { the view that is currently focused }
- gFreeWindowList: TList; { list of free-standing (documentless)
- windows }
- gGotClipType: BOOLEAN; { True if we can paste the data in the
- clipboard }
- gHeadCohandler: TEvtHandler; { head of linked list of global co-handlers
- }
- gIdlePhase: IdlePhase; { The current idle phase }
- gInBackground: BOOLEAN; { True if app is currently in background }
- gInitialized: BOOLEAN; { Set to TRUE at the end of IApplication }
- {$IFC qDebug}
- gIntenseDebugging: BOOLEAN; { debugging toggle for intensive debugging }
- {$ENDC}
- gLastClickPart: INTEGER; { the list window part clicked in-used for
- double click detection }
- gLastDeskAcc: LONGINT; { time of the most recent possible excursion
- to a a Desk Accessory }
- gLastMsePt: Point; { coordinates of mouse in last event passed
- to TApplication.CountClicks }
- gLastUpTime: LONGINT; { time of last mouse up event passed to
- TApplication.ObeyEvent }
- gLongOffset: VPoint; { Used in focusing }
- gLowSpaceInterval: LONGINT; { If >= 0, the frequency (in Ticks) with
- which MacApp displays a low space alert.
- (Defaults to kLowSpaceInterval.) If < 0,
- MacApp doesn't display an alert. }
- gMacAppAlertFilter: ProcPtr; { the default filter proc. Will be
- automatically set to point to
- MacAppAlertFilter. Set this to nil in your
- code if you don't want it or call it from
- your own filter proc if you just want to
- add behavior. Someday we will fix all this
- to be Object based. }
- gInFilter: BOOLEAN; { Flag that is set when we are in the
- MacAppAlertFilter, used to indicate if we
- should re-enter MacApp to handle updates
- or not }
- gInhibitNestedHandling: BOOLEAN; { TRUE if Failure was executed and the
- outer- most event loop has not been
- reached or the ErrorAlert routing has not
- yet shown the failure to the user. Also
- may be set to TRUE to inhibit continued
- operation of MacApp Activate/Update
- handling and idling during MacAppAlerts. }
- gMainEventMask: INTEGER; { Event mask used in main event loop.
- Initialized by InitUMacApp. }
- gMainFileType: OSType; { principal file type opened/printed by
- application; set in
- TApplication.IApplication; by default,
- TApplication.SFGetFilters returns a list
- of just this }
- gMBarDisplayed: INTEGER; { menus that are read in and installed in
- menu bar }
- gMBarHierarchical: INTEGER; { menus that pop up when a menu item is
- choosen }
- gMBarNotDisplayed: INTEGER; { menus that are read in but not installed }
- gNewScrapStuff: ScrapStuff; { the current ScrapStuff record used in
- tracking the scrap }
- gNextSpaceMsg: LONGINT; { time when next low space message should be
- displayed }
- gNullPrintHandler: TPrintHandler; { handles printing-relating messages for
- views which don't print }
- gNumUntitled: INTEGER; { The number to assign to the next Untitled
- document (assuming that the app provides a
- template for filling in the number. You
- must change STR# resource with ID 0 /
- index 3 to read (for example)
- Untitled-<<<#>>>. }
- gNoChanges: TCommand; { Value to return when the handler doesn't
- return a command. You can just use NIL
- now. (Left in for compatibility (2.0) }
- gOldChooserFlag: BOOLEAN; { The state of the chooser alert flag when
- the application started up. }
- gOldScrapStuff: ScrapStuff; { the last ScrapStuff record used in
- tracking the scrap }
- gOrthogonal: ARRAY [VHSelect] OF VHSelect; { An Orthogonal set of VHSelects.
- gOrthogonal[v] = h and
- gOrthogonal[h] = v }
- gPageOffset: VPoint; { offset in view of page being printed }
- gPrefClipType: ResType;
- gPrintHandler: TPrintHandler; { a global print-handler object for use in
- some standard printing-related activities;
- this is initialized to be just a reference
- to gNullPrintHandler, but if you call
- InitPrinting, that will install a
- non-trivial print-handler here… }
- gPrinting: BOOLEAN; { true if currently Printing }
- {$IFC qDebug}
- gReportEvt: BOOLEAN; { debugging toggle for reporting events }
- gReportMenuChoices: BOOLEAN; { debugging toggle for tracing cmds }
- gRsrcCheck: INTEGER; { debugging toggle for checking resource
- usage }
- {$ENDC}
-
- gSaveFocusRec: FocusRec; { a place to save off the focus to speed up
- scrolling}
-
- gSignatures: ARRAY [1..kMaxSignatures] OF IDType; { Standard object signatures }
- gSignatureIds: ARRAY [1..kMaxSignatures] OF ObjClassId; { corresponding standard
- object ClassIds }
- gSignatureCount: INTEGER; { count of standard signatures stored }
-
- gStdHysteresis: Point; { standard hysteresis used in
- TCommand.ICommand }
- gStdStaggerCount: INTEGER; { Used to stagger windows created from
- templates }
- gStdWMoveBounds: Rect; { standard boundsRect to pass to DragWindow
- Toolbox routine }
- gStdWSizeRect: Rect; { standard sizeRect to pass to GrowWindow
- Toolbox routine }
- gStdWScreenRect: Rect; { Used to force a window onto the screen. If
- the window is not in the GrayRgn, then at
- least one corner of the window must lie
- within gStdWScreenRect. }
-
- gSysWindowActive: BOOLEAN; { TRUE if the front window is a system
- window }
- gSystemStyle: TextStyle; { System's default text style }
- gTarget: TEvtHandler; { the TEvtHandler that gets the first chance
- at DoCommand, DoSetupMenu, DoKeyCommand,
- Idle; should never be NIL -- If you do not
- want your own target set this to the
- application object }
-
- gTempRgn: RgnHandle; { gTempRgn is a temporary RgnHandle created
- in InitUMacApp. When debugging: before
- using gTempRgn, call UseTempRgn and when
- done call DoneWithTempRgn; this ensures
- that 2 routines do not try to use gTempRgn
- and the same time }
- {$IFC qDebug}
- gTraceIdle: BOOLEAN; { allow tracing through idle }
- {$ENDC}
- gUndoState: BOOLEAN; { are we in undo or redo }
- gUndoCmd: CmdNumber; {}
- {$IFC qDebug}
- gUsedBy: Str255; { The routine using gTempRgn }
- {$ENDC}
- gVarClipPicSize: BOOLEAN; { if TRUE, Pictures in the Clipboard are
- treated as variable size, depending on the
- window size; if FALSE (default), then
- pictures in the Clipboard are drawn and
- pasted ??? actual size }
- {$IFC qDebug}
- gWasTrcEnable: BOOLEAN; { Used to store old tracing state across
- idleBegin/idleEnd calls to Idle }
- {$ENDC}
- gWResSignature: IDType; { Signature used by TView.WRes }
- gWResType: Str255; { Type used by TView.WRes }
- gWorkPort: GrafPtr; { Pointer to a graf port that is created
- during initialization }
-
- { Pascal doesn't have structured constants so… }
- gZeroRect: Rect; { SetRect(gZeroRect, 0, 0, 0, 0); }
- gZeroPt: Point; { SetPt(gZeroPt, 0, 0); }
- gZeroVPt: VPoint; { SetVPt(gZeroVPt, 0, 0); }
- gZeroVRect: VRect; { SetVRect(gZeroVRect, 0, 0, 0, 0); }
-
- { These are really private but, they're here in case access is needed. }
- pCopyright: StringHandle;
- pETSPatch: TrapPatch; { patch for ExitToShell }
- pFi: FailInfo; { Outermost failure handler }
-
- {--------------------------------------------------------------------------------------------------}
-
- { D E B U G G I N G }
-
- {$IFC qDebug}
-
- PROCEDURE DoneWithTempRgn;
- { Indicates that gTempRgn is no longer in use. Call this only if qDebug is true. }
-
- PROCEDURE EntDebugger(entering: BOOLEAN);
- { Call to enter the MacApp Debugger }
-
- PROCEDURE UseTempRgn(byWhom: Str255);
- { Call this when you are about to use gTempRgn and qDebug is true. Used with DoneWithTempRgn
- will prevent you from trying to use gTempRgn from two places at the same time. }
- {$ENDC qDebug}
-
- FUNCTION LookupSymbol(VAR sym: Str255): LONGINT;
- { Call to see if anyone knows a reference for the given symbol }
-
- PROCEDURE NotYetImplemented(where: Str255);
- { Signals the notYetImplemented failure which when caught puts up an alert saying
- "Not Yet Implemented" and in debug WriteLns where. }
-
- { W I N D O W S }
-
- FUNCTION FreeIfWMgrWindow(w: WindowPtr;
- dispose: BOOLEAN): WindowPtr;
- { Calls DisposeWindow if dispose is true, else calls CloseWindow. Does nothing if w
- is nil.
- Returns NIL for convenient assignment back to the reference passed in. } { Preferred }
-
-
- PROCEDURE FreeWMgrWindow(w: WindowPtr;
- dispose: BOOLEAN);
- { Left in for compatibility (2.0) }
-
- FUNCTION GetWindowVariant(theWindow: WindowPtr): INTEGER;
-
- FUNCTION NewPaletteWindow(itsRsrcID: INTEGER;
- wantHScrollBar, wantVScrollBar: BOOLEAN;
- itsDocument: TDocument;
- itsMainView: TView;
- itsPaletteView: TView;
- sizePalette: INTEGER;
- whichWay: VHSelect): TWindow;
- { Utility for creating MacDraw-like windows with 1 non-scrolling palette along the left edge
- (whichWay = h), or a non-scrolling status area at the top of the window (whichWay = v), and
- a main view that may or may not scroll. Signals Failure if the window could not be created.
- }
-
- FUNCTION NewSimpleWindow(itsRsrcID: INTEGER;
- wantHScrollBar, wantVScrollBar: BOOLEAN;
- itsDocument: TDocument;
- itsView: TView): TWindow;
- { Utility for creating simple windows that contain 1 view and may or may not scroll. Signals
- Failure if the window could not be created. }
-
- FUNCTION NewTWindow(itsRsrcID: INTEGER;
- itsDocument: TDocument): TWindow;
- { Utility for creating a window object. Used within NewPaletteWindow & NewSimpleWindow.
- SIgnals Failure if the window could not be created. }
-
- FUNCTION NewTemplateWindow(viewRsrcID: INTEGER;
- itsDocument: TDocument): TWindow;
- { Creates a window using a 'WIND' resource and a 'view' template. }
-
- FUNCTION ParseTitleTemplate(VAR itsTemplate: Str255;
- VAR preDocname, constTitle: INTEGER): BOOLEAN;
- { Used in TWindow.IWindow to parse the template for window titles. Returns TRUE if it changed
- the template. preDocname is start of document name in string; constChars is total #
- characters of window title that are constants. (These values are fixed regardless of the
- document name.) If preDocname is 0, then the entire title is constant. }
-
- FUNCTION SubstituteInTitle(VAR title: Str255;
- newStuff: Str255;
- preDocname, constTitle: INTEGER): BOOLEAN;
- { Substitutes newStuff into the template as parsed by ParseTitleTemplate; returns TRUE if a
- substitution was made. }
-
- { C L I P B O A R D }
-
- PROCEDURE CanPaste(aClipType: ResType);
- { Call this in your SetUpMenus code to register an ability to paste a particular type of
- Clipboard data }
-
- FUNCTION PutDeskScrapData(aResType: ResType;
- aDataHandle: Handle): OSerr;
- { Call this from your TCommand method 'WriteToDeskScrap' (for a Command which changes the
- Clipboard) to write out data to the actual Desk Scrap. The return code from the Scrap
- Manager is returned as the function value -- will be noErr unless something went wrong.
- This procedure leaves aDataHandle UNLOCKED. Rather than calling this, you can call the
- ToolBox routine PutScrap yourself }
-
- { E R R O R S }
-
- PROCEDURE ErrorAlert(err: OSerr;
- message: LONGINT);
- { Displays an error alert box. The message displayed in the alert is constructed base upon
- err and message, as described in the "Failure Handling" section of the "Cookbook" chapter
- of the MacApp manual. }
-
- FUNCTION LookupErrString(value: INTEGER;
- resourceID: INTEGER;
- VAR str: Str255): BOOLEAN;
- { Looks up an error value in an 'errs' resource and returns TRUE if found. resourceID should
- be that of a MacApp errs resource; we do the lookup first in errAppTable+resourceID, which
- applications can use to override or extend the MacApp table. If the value is not found, str
- will be empty. }
-
- FUNCTION MacAppAlert(alertID: INTEGER;
- filterProc: ProcPtr): INTEGER;
- { Does SetCursor(arrow) before calling Alert. }
-
- PROCEDURE StdAlert(alertID: INTEGER);
- { no filterProc, reply ignored }
-
- { V I E W R E S O U R C E U T I L I T I E S }
-
- PROCEDURE RegisterStdType(typeName: Str255;
- signature: IDType);
- { Associates the given class with a signature. }
-
- FUNCTION NewStdObject(signature: IDType): TObject;
- { Returns the prototype object for the given signature. }
-
- FUNCTION NewViewRsrc(VAR p: UNIV Ptr): ViewRsrcHndl;
- { Convenience routine to create a new view resource template handle. Passes back in "p" the
- pointer to the first template entry. }
-
- PROCEDURE DoneViewRsrc(viewRsrc: UNIV Handle;
- lastPtr: UNIV LONGINT);
- { Cuts back the handle to the proper length, based on lastPtr which should be the address of
- the next template entry. }
-
- FUNCTION ExpandPtr(viewRsrc: UNIV Handle;
- VAR p: UNIV LONGINT;
- offset: LONGINT): Ptr;
- { Bumps size of view resource if necessary to add a new template. Amount to bump is set to at
- least kViewRsrcExpandAmt over the current size. "p" is offset to point to the next
- available position for a new template. Returns the old value of p before it was updated. }
-
- FUNCTION ExpandPtrWStr(viewRsrc: UNIV Handle;
- VAR p: UNIV LONGINT;
- offset, len: LONGINT): Ptr;
- { Bumps size of view resource if necessary to add a new template which ends with a
- variable length string, the length of which is passed in len.
- Returns the old value of p before it was updated. }
-
- PROCEDURE OffsetPtr(VAR p: UNIV LONGINT;
- offset: LONGINT);
- { Adds offset to p, forcing word alignment.}
-
- PROCEDURE OffsetPtrWStr(VAR p: UNIV LONGINT;
- offset: LONGINT);
- { Adds offset to p, taking length of trailing variable length string into account, forcing
- word alignment.}
-
- { M I S C E L L A N E O U S }
-
- PROCEDURE ApplicationBeep;
- { If gApplication is not NIL just calls gApplication.Beep else it does a SysBeep.
- Removes a circular reference for UFailure.}
-
- FUNCTION CallAlertFilter(theDialog: DialogPtr;
- VAR theEvent: EventRecord;
- VAR itemHit: INTEGER;
- theAlertFilter: ProcPtr): BOOLEAN;
- INLINE $205F, { MOVE.L (A7)+,A0 }
- $4E90; { JSR (A0) }
- { Lets you call the alert filter specified in theAlertFilter. Useful for providing
- your own alert filter behaviour and then passing on to MacApp's }
-
- FUNCTION GetNewCenteredDialog(dialogID: INTEGER;
- dStorage: Ptr;
- behind: WindowPtr): DialogPtr;
- { The same as GetNewDialog except it centers the dialog on the screen and sets the cursor to
- an arrow. }
-
- PROCEDURE GetFocus(VAR theFocusRec: FocusRec);
- { gets the current focus into a focusrec. The focusrec.clipRgn must be a valid rgn useful for
- saving and restoring the focus behind MacApp's back.}
-
- PROCEDURE SetFocus(theFocusRec: FocusRec);
- { sets the current focus from a focus rec }
-
- PROCEDURE GetTextStyleFontInfo(theTextStyle: TextStyle; VAR theFontInfo: Fontinfo);
- { Returns the FontInfo record for the font/face/size specified in theTextStyle. Uses
- a temporary port so you don't have to. }
-
- PROCEDURE ExitMacApp;
- { Call this if for some reason you want to immediately exit the application. It calls
- gApplication.Terminate, cleans up some other internal stuff, and then calls ExitToShell.
- (Normally, you would not call this, because MacApp takes care of terminating the
- application.)}
-
- PROCEDURE InitUMacApp(callsToMoreMasters: INTEGER);
- { Initialize the UMacApp unit call this in your program after calling: InitToolBox and
- ValidateConfiguration. }
-
- PROCEDURE InstallIfPrintHandler(aPrintHandler: TPrintHandler; aView: TView);
- { Install a clone of aPrintHandler into the view if aPrintHandler is not the
- same as the null print handler. (Typically if printing is initialized.) This
- lets us install a print handler if printing is being used in the application
- and do NOTHING if it is not. }
-
- FUNCTION MacAppAlertFilter(theDialog: DialogPtr;
- VAR theEvent: EventRecord;
- VAR itemHit: INTEGER): BOOLEAN;
- { Default alert filter used throughout MacApp. Lets you answer yes and no to dialogs with
- keystrokes. Handles "cmd-." and escape. If the alert has not been called in a failure sequence
- then the application also handles update and activate events and idles. }
-
- FUNCTION MakeNewRgn: RgnHandle;
- { Calls NewRgn, then FailNIL}
-
- FUNCTION RectIsVisible(r: Rect): BOOLEAN;
- { Determine if a rect is visible in the current grafport. }
-
- PROCEDURE SetHLPenState(fromHL, toHL: HLState);
- { Set the pen state for highlighting by XOR, given the highlight transition. You can use this
- if you use Paint<X> or Frame<X> or line drawing for your highlighting. }
- { ??? Add a pattern parameter or make a helper routine that has a pattern parameter ??? }
-
- PROCEDURE FinderSegProc;
- { This is a dummy procedure to allow us to find the Finder segment }
-
- PROCEDURE CleanupMacApp;
- { Called as the final step of TApplication.Run }
- {$ENDC}
-
- PROCEDURE VisibleRect(VAR r: Rect);
- { Get the currently visible rectangle as defined by thePort clip region }
- {$IFC NOT UsingIncludes}
- END.
- {$ENDC}
-